Module: FacebookAds::FieldTypes
- Extended by:
- FieldTypes
- Included in:
- FieldTypes, Base
- Defined in:
- lib/facebook_ads/field_types.rb,
lib/facebook_ads/field_types/base.rb,
lib/facebook_ads/field_types/enum.rb,
lib/facebook_ads/field_types/list.rb,
lib/facebook_ads/field_types/double.rb,
lib/facebook_ads/field_types/object.rb,
lib/facebook_ads/field_types/boolean.rb,
lib/facebook_ads/field_types/integer.rb,
lib/facebook_ads/field_types/datetime.rb,
lib/facebook_ads/field_types/ad_object.rb,
lib/facebook_ads/field_types/string_type.rb,
lib/facebook_ads/field_types/upload_file.rb
Defined Under Namespace
Classes: AdObject, Base, Boolean, Double, Enum, Integer, List, MyDateTime, Object, StringType, UploadFile
Instance Method Summary
collapse
Instance Method Details
#for(type_spec) ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/facebook_ads/field_types.rb', line 34
def for(type_spec)
if type_spec.is_a?(Hash)
type_key = type_spec.keys[0]
if field_type = lookup(type_key)
field_type.new(type_spec[type_key])
else
raise "Invalid type: #{type_key}"
end
else
if (field_type = lookup(type_spec))
field_type.new
else
begin
ad_object_class = FacebookAds.const_get(type_spec)
field_type = lookup('ad_object')
field_type.new(ad_object_class)
rescue NameError
lookup('string').new
end
end
end
end
|
#lookup(type_name) ⇒ Object
30
31
32
|
# File 'lib/facebook_ads/field_types.rb', line 30
def lookup(type_name)
@@registry && @@registry[type_name]
end
|
#register(*type_names) ⇒ Object
23
24
25
26
27
28
|
# File 'lib/facebook_ads/field_types.rb', line 23
def register(*type_names)
@@registry ||= {}
type_names.each do |type_name|
@@registry[type_name] = self
end
end
|