Class: Tito::Types::Json

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

Instance Method Summary collapse

Instance Method Details

#cast(value) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/tito/types/json.rb', line 6

def cast(value)
  case value
  when Hash, Array then value
  when String then JSON.parse(value)
  when nil then nil
  else value
  end
end

#typeObject



4
# File 'lib/tito/types/json.rb', line 4

def type = :json