Sha256: 5d028e753304d472141bb00bc58409d3a813c43696ada11adc935bc435c447e4

Contents?: true

Size: 1.14 KB

Versions: 34

Compression:

Stored size: 1.14 KB

Contents

module FbGraph2
  class Edge < Collection
    attr_accessor :owner, :edge, :params, :options, :collection
    delegate :summary, :total_count, to: :collection

    def initialize(owner, edge, params = {}, options = {})
      self.owner = owner
      self.edge = edge
      self.params = params
      self.options = options
      self.collection = options.delete(:collection) || Collection.new
      replace collection
    end

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

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

Dir[File.join(__dir__, 'edge/*.rb')].each do |file|
  require file
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
fb_graph2-1.3.0 lib/fb_graph2/edge.rb
fb_graph2-1.2.0 lib/fb_graph2/edge.rb
fb_graph2-1.1.1 lib/fb_graph2/edge.rb
fb_graph2-1.1.0 lib/fb_graph2/edge.rb
fb_graph2-1.0.1 lib/fb_graph2/edge.rb
fb_graph2-1.0.0 lib/fb_graph2/edge.rb
fb_graph2-0.9.1 lib/fb_graph2/edge.rb
fb_graph2-0.9.0 lib/fb_graph2/edge.rb
fb_graph2-0.8.0 lib/fb_graph2/edge.rb
fb_graph2-0.7.9 lib/fb_graph2/edge.rb
fb_graph2-0.7.8 lib/fb_graph2/edge.rb
fb_graph2-0.7.7 lib/fb_graph2/edge.rb
fb_graph2-0.7.6 lib/fb_graph2/edge.rb
fb_graph2-0.7.5 lib/fb_graph2/edge.rb
fb_graph2-0.7.4 lib/fb_graph2/edge.rb
fb_graph2-0.7.3 lib/fb_graph2/edge.rb
fb_graph2-0.7.2 lib/fb_graph2/edge.rb
fb_graph2-0.7.1 lib/fb_graph2/edge.rb
fb_graph2-0.7.0 lib/fb_graph2/edge.rb
fb_graph2-0.6.2 lib/fb_graph2/edge.rb