Class: FacebookAds::FieldTypes::Object

Inherits:
Base
  • Object
show all
Defined in:
lib/facebook_ads/field_types/object.rb

Instance Method Summary collapse

Methods included from FacebookAds::FieldTypes

#for, #lookup, #register

Instance Method Details

#deserialize(value, session = nil) ⇒ Object



12
13
14
# File 'lib/facebook_ads/field_types/object.rb', line 12

def deserialize(value, session = nil)
  value.is_a?(String) ? JSON.parse(value) : value
end

#serialize(value) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/facebook_ads/field_types/object.rb', line 16

def serialize(value)
  # Only serialize if not primitive types. Otherwise json will add
  # Extra \" to the String/Int
  case value
    when String, Integer
      value
    else
      JSON.generate(value)
  end
end