Class: FacebookAds::FieldTypes::StringType

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

Overview

StringType instead of String to avoid name clash with the String class

Instance Method Summary collapse

Methods included from FacebookAds::FieldTypes

#for, #lookup, #register

Instance Method Details

#deserialize(value, session = nil) ⇒ Object



13
14
15
# File 'lib/facebook_ads/field_types/string_type.rb', line 13

def deserialize(value, session = nil)
  value.is_a?(Array) ? (value * ',') : value.to_s
end

#serialize(value) ⇒ Object



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

def serialize(value)
  case value
    when Hash
      JSON.generate(value)
    else
      value.to_s
  end
end