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



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

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



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

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

#value_classObject



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

def value_class
  Item
end