Sha256: 2a3536e4dd250d0743487a61afb701a9080789bc65250e3fd7d3cfea23c9bf66

Contents?: true

Size: 586 Bytes

Versions: 7

Compression:

Stored size: 586 Bytes

Contents

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

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

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

    %i(
      next_page
      prev_page
      retrieve
    ).each do |method|
      define_method(method) { self }
    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

7 entries across 7 versions & 1 rubygems

Version Path
eventbrite_sdk-3.0.9 lib/eventbrite_sdk/blank_resource_list.rb
eventbrite_sdk-3.0.8 lib/eventbrite_sdk/blank_resource_list.rb
eventbrite_sdk-3.0.7 lib/eventbrite_sdk/blank_resource_list.rb
eventbrite_sdk-3.0.6 lib/eventbrite_sdk/blank_resource_list.rb
eventbrite_sdk-3.0.5 lib/eventbrite_sdk/blank_resource_list.rb
eventbrite_sdk-3.0.4 lib/eventbrite_sdk/blank_resource_list.rb
eventbrite_sdk-3.0.3 lib/eventbrite_sdk/blank_resource_list.rb