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



24
25
26
# File 'lib/facebook_ads/field_types/object.rb', line 24

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

#serialize(value) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/facebook_ads/field_types/object.rb', line 28

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