Class: FacebookAds::ParamSet
- Inherits:
-
Object
- Object
- FacebookAds::ParamSet
- Defined in:
- lib/facebook_ads/param_set.rb
Instance Method Summary collapse
- #accepts_files! ⇒ Object
- #accepts_files? ⇒ Boolean
-
#deserialize(data) ⇒ Object
TODO.
- #empty? ⇒ Boolean
- #from_params(data) ⇒ Object
- #has_param(name, type) ⇒ Object
-
#initialize ⇒ ParamSet
constructor
A new instance of ParamSet.
- #to_params(data) ⇒ Object
Constructor Details
#initialize ⇒ ParamSet
Returns a new instance of ParamSet.
9 10 11 12 |
# File 'lib/facebook_ads/param_set.rb', line 9 def initialize @params = {} @accepts_files = false end |
Instance Method Details
#accepts_files! ⇒ Object
18 19 20 |
# File 'lib/facebook_ads/param_set.rb', line 18 def accepts_files! @accepts_files = true end |
#accepts_files? ⇒ Boolean
22 23 24 |
# File 'lib/facebook_ads/param_set.rb', line 22 def accepts_files? @accepts_files end |
#deserialize(data) ⇒ Object
TODO
54 55 56 |
# File 'lib/facebook_ads/param_set.rb', line 54 def deserialize(data) from_params(data) end |
#empty? ⇒ Boolean
58 59 60 |
# File 'lib/facebook_ads/param_set.rb', line 58 def empty? @params.empty? end |
#from_params(data) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/facebook_ads/param_set.rb', line 44 def from_params(data) Hash[data.map do |key,val| key = key.to_sym field_type = @params[key] [key, (field_type ? field_type.deserialize(val) : val)] end] end |
#has_param(name, type) ⇒ Object
14 15 16 |
# File 'lib/facebook_ads/param_set.rb', line 14 def has_param(name, type) @params[name.to_sym] = FieldTypes.for(type) end |
#to_params(data) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/facebook_ads/param_set.rb', line 26 def to_params(data) Hash[data.map do |key,val| key = key.to_sym field_type = @params[key] if (!field_type && accepts_files? && FieldTypes::UploadFile.acceptable?(val)) field_type = FieldTypes::UploadFile.new end if (!field_type && val.is_a?(Array)) # dynamic ads val = JSON.generate(val) end [key, (field_type ? field_type.serialize(val) : val)] # TODO CollectionProxy= end] end |