1
0
Fork 0
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:
nov 2014-05-05 20:38:39 +09:00
parent 02f066c357
commit c53014cd48
6 changed files with 9 additions and 14 deletions

View file

@ -1,7 +1,5 @@
module FbGraph2 module FbGraph2
class Application < Node class Application < Node
include AttributeAssigner
register_attributes( register_attributes(
raw: [ raw: [
:id, :android_key_hash, :app_domains, :auth_dialog_data_help_url, :auth_dialog_headline, :id, :android_key_hash, :app_domains, :auth_dialog_data_help_url, :auth_dialog_headline,
@ -23,7 +21,6 @@ module FbGraph2
def initialize(id, attributes = {}) def initialize(id, attributes = {})
super super
assign attributes
# TODO: handle custom attributes. # TODO: handle custom attributes.
end end
end end

View file

@ -35,13 +35,13 @@ module FbGraph2
when :page when :page
Page.new raw[:id], raw Page.new raw[:id], raw
when :pages when :pages
Collection.new(raw).each do |_raw_| Collection.new(raw).collect do |_raw_|
Page.new _raw_[:id], _raw_ Page.new _raw_[:id], _raw_
end end
when :profile when :profile
as_profile raw as_profile raw
when :profiles when :profiles
Collection.new(raw).each do |_raw_| Collection.new(raw).collect do |_raw_|
as_profile _raw_ as_profile _raw_
end end
when :user when :user
@ -55,6 +55,8 @@ module FbGraph2
end end
end end
private
def as_profile(raw) def as_profile(raw)
klass = if raw.include?(:namespace) klass = if raw.include?(:namespace)
Application Application

View file

@ -2,8 +2,13 @@ module FbGraph2
class Node class Node
attr_accessor :id, :access_token, :raw_attributes attr_accessor :id, :access_token, :raw_attributes
def self.inherited(klass)
klass.include AttributeAssigner
end
def initialize(id, attributes = {}) def initialize(id, attributes = {})
self.id = id self.id = id
assign attributes if respond_to?(:assign)
end end
def authenticate(access_token) def authenticate(access_token)

View file

@ -1,7 +1,5 @@
module FbGraph2 module FbGraph2
class Page < Node class Page < Node
include AttributeAssigner
register_attributes( register_attributes(
raw: [ raw: [
:about, :attire, :band_members, :booking_agent, :can_post, :category, :checkins, :company_overview, :about, :attire, :band_members, :booking_agent, :can_post, :category, :checkins, :company_overview,
@ -21,7 +19,6 @@ module FbGraph2
def initialize(id, attributes = {}) def initialize(id, attributes = {})
super super
assign attributes
# TODO: handle custom attributes. # TODO: handle custom attributes.
end end
end end

View file

@ -1,7 +1,5 @@
module FbGraph2 module FbGraph2
class Post < Node class Post < Node
include AttributeAssigner
register_attributes( register_attributes(
raw: [ raw: [
:caption, :description, :icon, :is_hidden, :link, :message, :name, :object_id, :picture, :caption, :description, :icon, :is_hidden, :link, :message, :name, :object_id, :picture,
@ -19,7 +17,6 @@ module FbGraph2
def initialize(id, attributes = {}) def initialize(id, attributes = {})
super super
assign attributes
# TODO: handle custom attributes. # TODO: handle custom attributes.
end end
end end

View file

@ -1,7 +1,5 @@
module FbGraph2 module FbGraph2
class User < Node class User < Node
include AttributeAssigner
include Edge::Accounts include Edge::Accounts
include Edge::Friends include Edge::Friends
include Edge::Feed include Edge::Feed
@ -22,7 +20,6 @@ module FbGraph2
def initialize(id, attributes = {}) def initialize(id, attributes = {})
super super
assign attributes
# TODO: handle custom attributes. # TODO: handle custom attributes.
end end