Sha256: e4e58eb6cec97b073b4045f539225ddf83496370fef2d0f9aa5f177d6ac4e328

Contents?: true

Size: 904 Bytes

Versions: 13

Compression:

Stored size: 904 Bytes

Contents

module FbGraph
  class Connection < Collection
    attr_accessor :collection, :connection, :owner, :options
    delegate :total_count, :to => :collection

    def initialize(owner, connection, options = {})
      @owner = owner
      @options = options
      @connection = connection
      @collection = options.delete(:collection) || Collection.new
      replace collection
    end

    def next(_options_ = {})
      if self.collection.next.present?
        self.owner.send(self.connection, self.options.merge(_options_).merge(self.collection.next))
      else
        self.class.new(self.owner, self.connection)
      end
    end

    def previous(_options_ = {})
      if self.collection.previous.present?
        self.owner.send(self.connection, self.options.merge(_options_).merge(self.collection.previous))
      else
        self.class.new(self.owner, self.connection)
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
fb_graph-2.1.4 lib/fb_graph/connection.rb
fb_graph-2.1.3 lib/fb_graph/connection.rb
fb_graph-2.1.2 lib/fb_graph/connection.rb
fb_graph-2.1.1 lib/fb_graph/connection.rb
fb_graph-2.1.0 lib/fb_graph/connection.rb
fb_graph-2.1.0.alpha lib/fb_graph/connection.rb
fb_graph-2.0.2 lib/fb_graph/connection.rb
fb_graph-2.0.1 lib/fb_graph/connection.rb
fb_graph-2.0.0 lib/fb_graph/connection.rb
fb_graph-2.0.0.beta lib/fb_graph/connection.rb
fb_graph-2.0.0.alpha lib/fb_graph/connection.rb
fb_graph-1.9.5 lib/fb_graph/connection.rb
fb_graph-1.9.4 lib/fb_graph/connection.rb