Method: FbGraph::Post#initialize

Defined in:
lib/fb_graph/post.rb

#initialize(identifier, options = {}) ⇒ Post

Returns a new instance of Post.



7
8
9
10
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
40
41
42
43
44
45
46
# File 'lib/fb_graph/post.rb', line 7

def initialize(identifier, options = {})
  super
  if (from = options[:from])
    @from = if from[:category]
      FbGraph::Page.new(from.delete(:id), from)
    else
      FbGraph::User.new(from.delete(:id), from)
    end
  end
  @to = []
  if options[:to]
    FbGraph::Collection.new(options[:to]).each do |to|
      @to << if to[:category]
        FbGraph::Page.new(to.delete(:id), to)
      else
        FbGraph::User.new(to.delete(:id), to)
      end
    end
  end
  @message     = options[:message]
  @picture     = options[:picture]
  @link        = options[:link]
  @name        = options[:name]
  @caption     = options[:caption]
  @description = options[:description]
  @source      = options[:source]
  @icon        = options[:icon]
  @attribution = options[:attribution]
  @actions     = options[:actions]
  @likes       = options[:likes]
  if options[:created_time]
    @created_time = Time.parse(options[:created_time]).utc
  end
  if options[:updated_time]
    @updated_time = Time.parse(options[:updated_time]).utc
  end

  # cached connection
  @_comments_ = FbGraph::Collection.new(options[:comments])
end