Module: Zuck::FbObject::Read

Included in:
RawFbObject
Defined in:
lib/zuck/fb_object/read.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
# File 'lib/zuck/fb_object/read.rb', line 4

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#initialize(graph, data = {}, parent = nil) ⇒ Object

Parameters:

  • graph (Koala::Facebook::API)

    A graph with access_token

  • data (Hash) (defaults to: {})

    The properties you want to assign, this is what facebook gave us (see known_keys).

  • parent (<FbObject] A parent context for this class, must inherit from {Zuck::FbObject}) (defaults to: nil)

    arent [<FbObject] A parent context for this class, must inherit from Zuck::FbObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/zuck/fb_object/read.rb', line 13

def initialize(graph, data = {}, parent=nil)
  self.graph = graph
  set_data(data)

  # If the parent is an {AdAccount} we only want to set it as this
  # object's direct parent when this object is an {AdCampaign}.
  if !parent.is_a?(AdAccount) or parent.is_a?(AdAccount) and self.is_a?(AdCampaign)
    set_parent(parent)
  end
end

#reloadObject

Refetches the data from façeboko



25
26
27
28
29
# File 'lib/zuck/fb_object/read.rb', line 25

def reload
  data = get(graph, path)
  set_data(data)
  self
end