Method: GSGraph::OpenGraph::Action#initialize
- Defined in:
- lib/gs_graph/open_graph/action.rb
#initialize(identifier, attributes = {}) ⇒ Action
Returns a new instance of Action.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/gs_graph/open_graph/action.rb', line 11 def initialize(identifier, attributes = {}) super @raw_attributes = attributes @type = attributes[:type] if application = attributes[:application] @application = Application.new(application[:id], application) end if from = attributes[:from] @from = User.new(from[:id], from) end @objects = {} if attributes[:data] attributes[:data].each do |key, _attributes_| @objects[key] = case _attributes_ when Hash Object.new _attributes_[:id], _attributes_ else _attributes_ end end end @objects = @objects.with_indifferent_access [:start_time, :end_time, :publish_time].each do |key| self.send "#{key}=", Time.parse(attributes[key]) if attributes[key] end # cached connection cache_collections attributes, :comments, :likes end |