Class: NumberedList::MarshallBase

Inherits:
ActiveRecord::Type::Value
  • Object
show all
Defined in:
lib/numbered_list/marshall_base.rb

Instance Method Summary collapse

Instance Method Details

#cast(value) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/numbered_list/marshall_base.rb', line 8

def cast(value)
  if value.nil?
    return nil
  end
  if value.is_a?(Hash)
    value_class.new(value["name"])
  else
    value_class.new(value.to_s)
  end
end

#serialize(value) ⇒ Object



19
20
21
# File 'lib/numbered_list/marshall_base.rb', line 19

def serialize(value)
  value.nil? || value.blank? ? nil : value.to_s
end

#value_classObject



4
5
6
# File 'lib/numbered_list/marshall_base.rb', line 4

def value_class
  Item
end