Sha256: 58cddd7e76412a569d65178759b29c74dd38f0f5385730592b78a77cef24a71f

Contents?: true

Size: 1.48 KB

Versions: 1

Compression:

Stored size: 1.48 KB

Contents

module FbGraph
  class Post < Node
    include Connections::Comments

    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])
      end
      if options[:updated_time]
        @updated_time = Time.parse(options[:updated_time])
      end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fb_graph-0.0.8 lib/fb_graph/post.rb