Sha256: 8cfe52b7b9191565add4c43ffd211bc83783eaf51cc3a4aba10572c0b27958ee

Contents?: true

Size: 791 Bytes

Versions: 28

Compression:

Stored size: 791 Bytes

Contents

module FbGraph
  class PromotablePost < Post
    attr_accessor :is_published, :scheduled_publish_time

    def initialize(identifier, attributes = {})
      super
      @is_published = attributes[:is_published]
      @scheduled_publish_time = if attributes[:scheduled_publish_time]
        Time.at attributes[:scheduled_publish_time]
      end
    end

    def publishable?
      !@is_published
    end
    alias_method :schedulable?, :publishable?

    def scheduled?
      !!scheduled_publish_time
    end

    def publish!(options = {})
      update options.merge(:is_published => true)
    end

    def schedule!(time, options = {})
      update options.merge(:scheduled_publish_time => time.to_i)
    end

    def unschedule!(options = {})
      schedule! nil, options
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
fb_graph-2.6.5 lib/fb_graph/promotable_post.rb
fb_graph-2.6.4 lib/fb_graph/promotable_post.rb
fb_graph-2.6.3 lib/fb_graph/promotable_post.rb
fb_graph-2.6.2 lib/fb_graph/promotable_post.rb
fb_graph-2.6.1 lib/fb_graph/promotable_post.rb
fb_graph-2.6.0 lib/fb_graph/promotable_post.rb
fb_graph-2.5.9 lib/fb_graph/promotable_post.rb
fb_graph-2.5.8 lib/fb_graph/promotable_post.rb