class NgrokAPI::Models::Listable

A resource representing multiple instances from a given “list” API call

Attributes

attrs[R]
client[R]
items[R]
iter[R]
klass[R]
list_property[R]
next_page_uri[R]
uri[R]

Public Class Methods

new(danger: false, client:, attrs:, list_property:, klass:) click to toggle source
# File lib/ngrokapi/models/listable.rb, line 19
def initialize(danger: false, client:, attrs:, list_property:, klass:)
  @client = client
  @attrs = attrs
  @list_property = list_property
  @next_page_uri = @attrs['next_page_uri']
  @uri = @attrs['uri']
  @items = @attrs[list_property].map do |item|
    klass.new(client: client, attrs: item)
  end
  @iter = NgrokAPI::PagedIterator.new(
    client: client,
    page: self,
    list_property: list_property,
    danger: danger
  )
end

Public Instance Methods

==(other) click to toggle source
# File lib/ngrokapi/models/listable.rb, line 44
def ==(other)
  @attrs == other.attrs
end
each() { |item| ... } click to toggle source
# File lib/ngrokapi/models/listable.rb, line 36
def each
  item = @iter.get_next
  while item
    yield item
    item = @iter.get_next
  end
end
to_s() click to toggle source
# File lib/ngrokapi/models/listable.rb, line 48
def to_s
  @attrs.to_s
end