Class: Zuck::FbObject::RawFbObject
- Inherits:
-
Object
- Object
- Zuck::FbObject::RawFbObject
- Extended by:
- Helpers
- Includes:
- DSL, Helpers, Read, Write, HashDelegator, KoalaMethods
- Defined in:
- lib/zuck/fb_object.rb
Overview
An object that includes HashDelegator for easy hash
access and default keys as methods as well as the graph
getter and setter from Koala::Methods.
By inheriting from this object, each fb object gets implemented automatically (tm) through calling a couple of DSL methods and defining how an object can obtain its own path.
I feel it is example time, here's an imaginary ad campaign:
class AdCampaign < FbObject
known_keys :title, :budget
parent_object :ad_account
list_path :adcampaigns
connections :ad_groups
end
These handy things are now provided by Zuck::FbObject to your object:
- Each
AdCampaign
object has atitle
andbudget
method. In case facebook returned more information than what's documented (there are a lot of these), you can still callmy_campaign[:secret_key]
to get to the juicy bits - You can call
AdCampaign.all(graph, my_ad_account)
, because yourAdCampaign
instance knows how to construct the pathact_12345/adcampaigns
. It knows this, because it knows its parent object and its own list path. - You can call
#ad_groups
on anyAdCampaign
instance to fetch the ad groups in that campaign. To add an ad_group to a campaign, you can callAdGroup.create(graph, data, my_campaign)
, or for short:my_campaign.create_ad_group(data)
Method Summary
Methods included from Write
Methods included from Read
included, #initialize, #reload