Sha256: 0cf29535b8953ed428a18e992ff9c61ecf281c3df2c0f9e123d9ee3557ac9893

Contents?: true

Size: 662 Bytes

Versions: 4

Compression:

Stored size: 662 Bytes

Contents

module EventbriteSDK
  # An Empty resource listing, returned on ORM calls from new resources
  class BlankResourceList
    extend Forwardable
    include Enumerable

    def_delegators :@objects, :[], :concat, :each, :empty?, :to_ary

    def initialize(key: nil)
      @key = key
      @objects = []
    end

    %i(
      next_page
      prev_page
      retrieve
    ).each do |method|
      define_method(method) { self }
    end

    def concat(other)
      other.concat(to_ary)
    end

    def page(_num)
      self
    end

    def with_expansion(*_args)
      self
    end

    def to_json(opts = {})
      { @key => [] }.to_json(opts)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
eventbrite_sdk-3.1.1 lib/eventbrite_sdk/blank_resource_list.rb
eventbrite_sdk-3.1.0 lib/eventbrite_sdk/blank_resource_list.rb
eventbrite_sdk-3.0.11 lib/eventbrite_sdk/blank_resource_list.rb
eventbrite_sdk-3.0.10 lib/eventbrite_sdk/blank_resource_list.rb