Class: GlueGun::Types::HashType

Inherits:
ActiveModel::Type::Value
  • Object
show all
Defined in:
lib/glue_gun/types/hash_type.rb

Instance Method Summary collapse

Instance Method Details

#cast(value) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/glue_gun/types/hash_type.rb', line 4

def cast(value)
  case value
  when String
    JSON.parse(value)
  when Hash
    value
  else
    {}
  end
end

#serialize(value) ⇒ Object



15
16
17
# File 'lib/glue_gun/types/hash_type.rb', line 15

def serialize(value)
  value.to_json
end