class Orchestrate::RefList

An enumerator over a query for listing Ref values in an Orchestrate::KeyValue.

Attributes

key_value[RW]

@return [KeyValue]

Public Class Methods

new(key_value) click to toggle source

Instantiates a new RefList @param key_value [KeyValue] The KeyValue item to retrieve Refs for.

# File lib/orchestrate/refs.rb, line 26
def initialize(key_value)
  @key_value = key_value
end

Public Instance Methods

[](ref_id) click to toggle source

Accessor for individual Refs. @param ref_id [#to_s] The ref of the specific immutable value to retrieve.

# File lib/orchestrate/refs.rb, line 32
def [](ref_id)
  response = @key_value.perform(:get, ref_id)
  Ref.new(@key_value.collection, @key_value.key, response)
end
each(&block) click to toggle source

Iterates over each Ref for the KeyValue. Used as the basis for Enumerable. Refs are provided in time-series order, newest to oldest. @overload each

@return Enumerator

@overload each(&block)

@yieldparam [Ref] ref the Ref item

@see RefList::Fetcher#each @example

ref_ids = kv.refs.take(20).map(&:ref)
# File lib/orchestrate/refs.rb, line 50
def each(&block)
  Fetcher.new(self).each(&block)
end
lazy() click to toggle source

Creates a Lazy Enumerator for the RefList. If called inside the Applciation’s ‘#in_parallel` block, pre-fetches the first page of results. @return [Enumerator::Lazy]

# File lib/orchestrate/refs.rb, line 57
def lazy
  Fetcher.new(self).lazy
end
offset(count) click to toggle source

Set the offset for the query to Orchestrate, so you can skip items. Does not fetch results. Implemented as a separate method from drop, unlike take, because take is a more common use case. @return [RefList::Fetcher]

# File lib/orchestrate/refs.rb, line 73
def offset(count)
  Fetcher.new(self).offset(count)
end
take(count) click to toggle source

Returns the first n items. Equivalent to Enumerable#take. Sets the ‘limit` parameter on the query to Orchestrate, so we don’t ask for more items than desired. @return [Array<Ref>]

# File lib/orchestrate/refs.rb, line 65
def take(count)
  Fetcher.new(self).take(count)
end
with_values() click to toggle source

Specifies that the query to Orchestrate should use the ‘values` parameter, and that the query should return the values for each ref. @return [RefList::Fetcher]

# File lib/orchestrate/refs.rb, line 80
def with_values
  Fetcher.new(self).with_values
end