Method: Zuck::FbObject::Read::ClassMethods#all
- Defined in:
- lib/zuck/fb_object/read.rb
#all(graph = Zuck.graph, parent = nil) ⇒ Object
Automatique all getter.
Let's say you want to fetch all campaigns
from facebook. This can happen in the context of an ad
account. In this gem, that context is called a parent. This method
would only be called on objects that inherit from Zuck::FbObject.
It asks the parent for it's path (if it is given), and appends
it's own list_path property that you have defined (see
list_path)
If, however, you want to fetch all ad creatives, regardless of
which ad group is their parent, you can omit the parent
parameter. The creatives returned by Zuck::AdCreative.all will
return nil when you call #ad_group on them, though, because facebook
will not return this information. So if you can, try to fetch
objects through their direct parent, e.g.
my_ad_group.ad_creatives.
70 71 72 73 74 75 76 |
# File 'lib/zuck/fb_object/read.rb', line 70 def all(graph = Zuck.graph, parent = nil) parent ||= parent_ad_account_fallback r = get(graph, path_with_parent(parent)) r.map do |c| new(graph, c, parent) end end |