Sha256: ebb0700eaff59f8ff5fb6aaa979ba01711604df93e3ff06a9936b2a7ef253d70

Contents?: true

Size: 1.51 KB

Versions: 2

Compression:

Stored size: 1.51 KB

Contents

module FbGraph
  class Post < Node
    include Connections::Comments
    extend Searchable

    attr_accessor :from, :to, :message, :picture, :link, :name, :caption, :description, :source, :icon, :attribution, :actions, :likes, :created_time, :updated_time

    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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fb_graph-0.7.0 lib/fb_graph/post.rb
fb_graph-0.6.0 lib/fb_graph/post.rb