mirror of
https://github.com/nov/fb_graph2
synced 2023-03-27 23:22:15 -04:00
make FbGraph::Node handle AttributeAssigner without include it.
This commit is contained in:
parent
02f066c357
commit
c53014cd48
6 changed files with 9 additions and 14 deletions
|
@ -1,7 +1,5 @@
|
|||
module FbGraph2
|
||||
class Application < Node
|
||||
include AttributeAssigner
|
||||
|
||||
register_attributes(
|
||||
raw: [
|
||||
:id, :android_key_hash, :app_domains, :auth_dialog_data_help_url, :auth_dialog_headline,
|
||||
|
@ -23,7 +21,6 @@ module FbGraph2
|
|||
|
||||
def initialize(id, attributes = {})
|
||||
super
|
||||
assign attributes
|
||||
# TODO: handle custom attributes.
|
||||
end
|
||||
end
|
||||
|
|
|
@ -35,13 +35,13 @@ module FbGraph2
|
|||
when :page
|
||||
Page.new raw[:id], raw
|
||||
when :pages
|
||||
Collection.new(raw).each do |_raw_|
|
||||
Collection.new(raw).collect do |_raw_|
|
||||
Page.new _raw_[:id], _raw_
|
||||
end
|
||||
when :profile
|
||||
as_profile raw
|
||||
when :profiles
|
||||
Collection.new(raw).each do |_raw_|
|
||||
Collection.new(raw).collect do |_raw_|
|
||||
as_profile _raw_
|
||||
end
|
||||
when :user
|
||||
|
@ -55,6 +55,8 @@ module FbGraph2
|
|||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def as_profile(raw)
|
||||
klass = if raw.include?(:namespace)
|
||||
Application
|
||||
|
|
|
@ -2,8 +2,13 @@ module FbGraph2
|
|||
class Node
|
||||
attr_accessor :id, :access_token, :raw_attributes
|
||||
|
||||
def self.inherited(klass)
|
||||
klass.include AttributeAssigner
|
||||
end
|
||||
|
||||
def initialize(id, attributes = {})
|
||||
self.id = id
|
||||
assign attributes if respond_to?(:assign)
|
||||
end
|
||||
|
||||
def authenticate(access_token)
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
module FbGraph2
|
||||
class Page < Node
|
||||
include AttributeAssigner
|
||||
|
||||
register_attributes(
|
||||
raw: [
|
||||
:about, :attire, :band_members, :booking_agent, :can_post, :category, :checkins, :company_overview,
|
||||
|
@ -21,7 +19,6 @@ module FbGraph2
|
|||
|
||||
def initialize(id, attributes = {})
|
||||
super
|
||||
assign attributes
|
||||
# TODO: handle custom attributes.
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
module FbGraph2
|
||||
class Post < Node
|
||||
include AttributeAssigner
|
||||
|
||||
register_attributes(
|
||||
raw: [
|
||||
:caption, :description, :icon, :is_hidden, :link, :message, :name, :object_id, :picture,
|
||||
|
@ -19,7 +17,6 @@ module FbGraph2
|
|||
|
||||
def initialize(id, attributes = {})
|
||||
super
|
||||
assign attributes
|
||||
# TODO: handle custom attributes.
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
module FbGraph2
|
||||
class User < Node
|
||||
include AttributeAssigner
|
||||
|
||||
include Edge::Accounts
|
||||
include Edge::Friends
|
||||
include Edge::Feed
|
||||
|
@ -22,7 +20,6 @@ module FbGraph2
|
|||
|
||||
def initialize(id, attributes = {})
|
||||
super
|
||||
assign attributes
|
||||
# TODO: handle custom attributes.
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue