class Moneta::Enumerable

Adds the Ruby {Enumerable} API to the store. The underlying store must support ‘:each_key`.

@example Adding to a builder

Moneta.build do
  # It should be the top middleware
  use :Enumerable
  adapter :DBM
end

@api public

Public Class Methods

new(adapter, options = {}) click to toggle source
Calls superclass method
# File lib/moneta/enumerable.rb, line 16
def initialize(adapter, options = {})
  raise "Adapter must support :each_key" unless adapter.supports? :each_key
  super
end

Public Instance Methods

each() { |key, load(key)| ... } click to toggle source

Enumerate over all pairs in the store

@overload each

@return [Enumerator]

@overload each

@yieldparam pair [Array<(Object, Object)>] Each pair is yielded
@return [self]
# File lib/moneta/enumerable.rb, line 30
def each
  return enum_for(:each) unless block_given?
  each_key { |key| yield key, load(key) }
  self
end
Also aliased as: each_pair
each_pair()
Alias for: each