mirror of
https://github.com/nov/fb_graph2
synced 2023-03-27 23:22:15 -04:00
parent
234234e42f
commit
1372dcc93b
4 changed files with 62 additions and 3 deletions
|
@ -7,7 +7,7 @@ module FbGraph2
|
||||||
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,
|
||||||
:source, :story
|
:source, :status_type, :story, :type
|
||||||
],
|
],
|
||||||
time: [:created_time, :updated_time],
|
time: [:created_time, :updated_time],
|
||||||
app: [:application],
|
app: [:application],
|
||||||
|
@ -16,13 +16,28 @@ module FbGraph2
|
||||||
profiles: [:to, :with_tags],
|
profiles: [:to, :with_tags],
|
||||||
actions: [:actions],
|
actions: [:actions],
|
||||||
custom: [
|
custom: [
|
||||||
:message_tags, :privacy, :properties, :shares, :status_type, :type
|
:message_tags, :privacy, :properties
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
def initialize(id, attributes = {})
|
def initialize(id, attributes = {})
|
||||||
super
|
super
|
||||||
# TODO: handle custom attributes.
|
if attributes.include? :message_tags
|
||||||
|
self.message_tags = attributes[:message_tags].inject({}) do |message_tags, (key, values)|
|
||||||
|
_message_tags_ = values.collect do |value|
|
||||||
|
TaggedProfile.new value[:id], value
|
||||||
|
end
|
||||||
|
message_tags.merge! key => _message_tags_
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if attributes.include? :privacy
|
||||||
|
self.privacy = Struct::Privacy.new attributes[:privacy]
|
||||||
|
end
|
||||||
|
if attributes.include? :properties
|
||||||
|
self.properties = attributes[:properties].collect do |property|
|
||||||
|
Struct::Property.new property
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
9
lib/fb_graph2/struct/privacy.rb
Normal file
9
lib/fb_graph2/struct/privacy.rb
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
module FbGraph2
|
||||||
|
class Struct
|
||||||
|
class Privacy < Struct
|
||||||
|
register_attributes(
|
||||||
|
raw: [:description, :value, :friends, :allow, :deny]
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
9
lib/fb_graph2/struct/property.rb
Normal file
9
lib/fb_graph2/struct/property.rb
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
module FbGraph2
|
||||||
|
class Struct
|
||||||
|
class Property < Struct
|
||||||
|
register_attributes(
|
||||||
|
raw: [:name, :text, :href]
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
26
lib/fb_graph2/tagged_profile.rb
Normal file
26
lib/fb_graph2/tagged_profile.rb
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
module FbGraph2
|
||||||
|
class TaggedProfile < Node
|
||||||
|
register_attributes(
|
||||||
|
raw: [:id, :name, :type, :offset, :length],
|
||||||
|
custom: [:object]
|
||||||
|
)
|
||||||
|
|
||||||
|
def initialize(id, attributes = {})
|
||||||
|
super
|
||||||
|
self.object = klass.new self.id
|
||||||
|
end
|
||||||
|
|
||||||
|
def klass
|
||||||
|
klass = case self.type
|
||||||
|
when 'user'
|
||||||
|
User
|
||||||
|
when 'page'
|
||||||
|
Page
|
||||||
|
when 'group'
|
||||||
|
Group
|
||||||
|
when 'event'
|
||||||
|
Event
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue