mirror of
https://github.com/nov/fb_graph2
synced 2023-03-27 23:22:15 -04:00
reduce "custom" attributes
This commit is contained in:
parent
f4d856ed3f
commit
bb73e5190a
11 changed files with 58 additions and 25 deletions
|
@ -30,28 +30,40 @@ module FbGraph2
|
|||
Time.parse raw
|
||||
when :timestamp
|
||||
Time.at raw
|
||||
when :actions
|
||||
Collection.new(raw).collect do |_raw_|
|
||||
Struct::Action.new _raw_
|
||||
end
|
||||
when :album
|
||||
Album.new raw[:id], raw
|
||||
when :application
|
||||
Application.new raw[:id], raw
|
||||
when :comment
|
||||
Comment.new raw[:id], raw
|
||||
when :group
|
||||
Group.new raw[:id], raw
|
||||
when :image_sources
|
||||
Collection.new(raw).collect do |_raw_|
|
||||
Struct::ImageSource.new _raw_
|
||||
end
|
||||
when :page
|
||||
Page.new raw[:id], raw
|
||||
when :pages
|
||||
Collection.new(raw).collect do |_raw_|
|
||||
Page.new _raw_[:id], _raw_
|
||||
end
|
||||
when :photo
|
||||
Photo.new raw[:id], raw
|
||||
when :picture
|
||||
Struct::Picture.new raw[:data]
|
||||
when :profile
|
||||
as_profile raw
|
||||
when :profiles
|
||||
Collection.new(raw).collect do |_raw_|
|
||||
as_profile _raw_
|
||||
end
|
||||
when :application
|
||||
Application.new raw[:id], raw
|
||||
when :user
|
||||
User.new raw[:id], raw
|
||||
when :picture
|
||||
Struct::Picture.new raw[:data]
|
||||
when :album
|
||||
Album.new raw[:id], raw
|
||||
else
|
||||
# NOTE: handle these attributes in each class
|
||||
next
|
||||
|
|
|
@ -4,7 +4,9 @@ module FbGraph2
|
|||
raw: [:can_comment, :can_remove, :comment_count, :like_count, :message, :user_likes],
|
||||
time: [:created_time],
|
||||
user: [:from],
|
||||
custom: [:attachment, :message_tags, :parent]
|
||||
comment: [:parent],
|
||||
profiles: [:message_tags],
|
||||
custom: [:attachment]
|
||||
)
|
||||
|
||||
def initialize(id, attributes = {})
|
||||
|
|
|
@ -4,12 +4,9 @@ module FbGraph2
|
|||
raw: [:description, :is_date_only, :location, :name, :privacy, :ticket_uri, :timezone],
|
||||
time: [:end_time, :start_time, :updated_time],
|
||||
page: [:venue],
|
||||
custom: [:cover, :owner, :parent_group]
|
||||
profile: [:owner],
|
||||
group: [:parent_group],
|
||||
photo: [:cover]
|
||||
)
|
||||
|
||||
def initialize(id, attributes = {})
|
||||
super
|
||||
# TODO: handle custom attributes.
|
||||
end
|
||||
end
|
||||
end
|
|
@ -7,12 +7,8 @@ module FbGraph2
|
|||
:administrator, :bookmark_order, :unread
|
||||
],
|
||||
time: [:updated_time],
|
||||
custom: [:cover, :owner, :parent]
|
||||
profile: [:owner, :parent],
|
||||
photo: [:cover]
|
||||
)
|
||||
|
||||
def initialize(id, attributes = {})
|
||||
super
|
||||
# TODO: handle custom attributes.
|
||||
end
|
||||
end
|
||||
end
|
|
@ -12,8 +12,9 @@ module FbGraph2
|
|||
time: [:created_time],
|
||||
date: [:birthday],
|
||||
page: [:best_page],
|
||||
photo: [:cover],
|
||||
custom: [
|
||||
:category_list, :cover, :context, :hours, :location, :parking, :price_range, :restaurant_services,
|
||||
:category_list, :context, :hours, :location, :parking, :price_range, :restaurant_services,
|
||||
:restaurant_specialties
|
||||
]
|
||||
)
|
||||
|
|
|
@ -1,12 +1,17 @@
|
|||
module FbGraph2
|
||||
class Photo < Node
|
||||
register_attributes(
|
||||
raw: [:backdated_time_granularity, :height, :icon, :link, :name, :page_story_id, :picture, :position, :source, :width],
|
||||
raw: [
|
||||
:backdated_time_granularity, :height, :icon, :link, :name, :page_story_id, :picture, :position, :source, :width,
|
||||
# NOTE: as cover photo
|
||||
:offset_y, :offset_x
|
||||
],
|
||||
time: [:backdated_time, :created_time, :updated_time],
|
||||
page: [:place],
|
||||
profile: [:from],
|
||||
album: [:album],
|
||||
custom: [:images, :name_tags]
|
||||
image_sources: [:images],
|
||||
custom: [:name_tags]
|
||||
)
|
||||
end
|
||||
end
|
|
@ -12,8 +12,9 @@ module FbGraph2
|
|||
page: [:place],
|
||||
profile: [:from],
|
||||
profiles: [:to, :with_tags],
|
||||
actions: [:actions],
|
||||
custom: [
|
||||
:actions, :message_tags, :privacy, :properties, :shares, :status_type, :type
|
||||
:message_tags, :privacy, :properties, :shares, :status_type, :type
|
||||
]
|
||||
)
|
||||
|
||||
|
|
9
lib/fb_graph2/struct/action.rb
Normal file
9
lib/fb_graph2/struct/action.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
module FbGraph2
|
||||
class Struct
|
||||
class Action < Struct
|
||||
register_attributes(
|
||||
raw: [:name, :link]
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
9
lib/fb_graph2/struct/image_source.rb
Normal file
9
lib/fb_graph2/struct/image_source.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
module FbGraph2
|
||||
class Struct
|
||||
class ImageSource < Struct
|
||||
register_attributes(
|
||||
raw: [:height, :source, :width]
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
module FbGraph2
|
||||
class Struct
|
||||
class Poke < Struct
|
||||
class Score < Struct
|
||||
register_attributes(
|
||||
raw: [:score],
|
||||
user: [:user],
|
||||
|
|
|
@ -43,7 +43,8 @@ module FbGraph2
|
|||
page: [:hometown, :location],
|
||||
pages: [:favorite_athletes, :favorite_teams, :inspirational_people, :languages],
|
||||
user: [:significant_other],
|
||||
custom: [:age_range, :context, :cover, :currency, :education, :work]
|
||||
photo: [:cover],
|
||||
custom: [:age_range, :context, :currency, :education, :work]
|
||||
)
|
||||
|
||||
def initialize(id, attributes = {})
|
||||
|
|
Loading…
Reference in a new issue