class Arsenicum::Formatter::ActiveRecord

Constants

TYPE_ACTIVE_RECORD

Public Instance Methods

format_by_extension(value) click to toggle source
# File lib/arsenicum/formatter.rb, line 111
def format_by_extension(value)
  return {
      type: TYPE_ACTIVE_RECORD,
      class: value.class.name,
      id: value.id,
  } if value.is_a? ActiveRecord::Base
end
parse_by_extension(value) click to toggle source
# File lib/arsenicum/formatter.rb, line 119
def parse_by_extension(value)
  if value[:type] == TYPE_ACTIVE_RECORD
    klass = constaitize value[:class].to_sym
    klass.find value[:id]
  end
end