Class: Zuck::FbObject::RawFbObject

Inherits:
Object
  • Object
show all
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:

  1. Each AdCampaign object has a title and budget method. In case facebook returned more information than what's documented (there are a lot of these), you can still call my_campaign[:secret_key] to get to the juicy bits
  2. You can call AdCampaign.all(graph, my_ad_account), because your AdCampaign instance knows how to construct the path act_12345/adcampaigns. It knows this, because it knows its parent object and its own list path.
  3. You can call #ad_groups on any AdCampaign instance to fetch the ad groups in that campaign. To add an ad_group to a campaign, you can call AdGroup.create(graph, data, my_campaign), or for short: my_campaign.create_ad_group(data)

Method Summary

Methods included from Write

#destroy, included, #save

Methods included from Read

included, #initialize, #reload

Methods included from DSL

included, #path

Methods included from KoalaMethods

#graph, #graph=

Methods included from HashDelegator

#[], #[]=, #data, #data=, included, #set_data, #to_s