Class: FacebookAds::Edge

Inherits:
Object
  • Object
show all
Defined in:
lib/facebook_ads/edge.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, node, should_delegate, options) ⇒ Edge

Returns a new instance of Edge.



114
115
116
117
118
119
# File 'lib/facebook_ads/edge.rb', line 114

def initialize(name, node, should_delegate, options)
  @name = name
  @node = node
  @options = options || {}
  @should_delegate = should_delegate
end

Class Attribute Details

.param_set_for_deleteObject (readonly)

Returns the value of attribute param_set_for_delete.



136
137
138
# File 'lib/facebook_ads/edge.rb', line 136

def param_set_for_delete
  @param_set_for_delete
end

.param_set_for_getObject (readonly)

Returns the value of attribute param_set_for_get.



136
137
138
# File 'lib/facebook_ads/edge.rb', line 136

def param_set_for_get
  @param_set_for_get
end

.param_set_for_postObject (readonly)

Returns the value of attribute param_set_for_post.



136
137
138
# File 'lib/facebook_ads/edge.rb', line 136

def param_set_for_post
  @param_set_for_post
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



112
113
114
# File 'lib/facebook_ads/edge.rb', line 112

def name
  @name
end

#nodeObject (readonly)

Returns the value of attribute node.



112
113
114
# File 'lib/facebook_ads/edge.rb', line 112

def node
  @node
end

#optionsObject (readonly)

Returns the value of attribute options.



112
113
114
# File 'lib/facebook_ads/edge.rb', line 112

def options
  @options
end

#should_delegateObject (readonly)

Returns the value of attribute should_delegate.



112
113
114
# File 'lib/facebook_ads/edge.rb', line 112

def should_delegate
  @should_delegate
end

Class Method Details

.delete(return_type = 'AdObject') {|(@param_set_for_delete = ParamSet.new)| ... } ⇒ Object

Yields:



154
155
156
157
158
159
160
# File 'lib/facebook_ads/edge.rb', line 154

def delete(return_type = 'AdObject')
  include EdgeHasDelete

  yield (@param_set_for_delete = ParamSet.new) if block_given?

  return_types(:delete, return_type)
end

.get(return_type = 'AdObject') {|(@param_set_for_get = ParamSet.new)| ... } ⇒ Object

Yields:



138
139
140
141
142
143
144
# File 'lib/facebook_ads/edge.rb', line 138

def get(return_type = 'AdObject')
  include EdgeHasGet

  yield (@param_set_for_get = ParamSet.new) if block_given?

  return_types(:get, return_type)
end

.post(return_type = 'AdObject') {|(@param_set_for_post = ParamSet.new)| ... } ⇒ Object

Yields:



146
147
148
149
150
151
152
# File 'lib/facebook_ads/edge.rb', line 146

def post(return_type = 'AdObject')
  include EdgeHasPost

  yield (@param_set_for_post = ParamSet.new) if block_given?

  return_types(:post, return_type)
end

.return_types(action = nil, return_type = nil) ⇒ Object

TODO refactor?



163
164
165
166
167
168
169
170
171
172
173
# File 'lib/facebook_ads/edge.rb', line 163

def return_types(action = nil, return_type = nil)
  if action
    if return_type
      @return_types ||= {}
      @return_types[action] = FieldTypes.for(return_type)
    end
    @return_types[action]
  else
    @return_types
  end
end

Instance Method Details

#graph_paramsObject

TODO refactor sending this along with params to leverage read-after-write



131
132
133
# File 'lib/facebook_ads/edge.rb', line 131

def graph_params
  {fields: options[:fields]}.compact
end

#serialized_optionsObject



121
122
123
124
125
126
127
# File 'lib/facebook_ads/edge.rb', line 121

def serialized_options
  Hash[options.map { |k,v|
    v = (k == :fields && v.is_a?(Array)) ?
         v.join(',') : v
    [k,v]
  }]
end