Class: Moneta::Enumerable
- Includes:
- Enumerable
- Defined in:
- lib/moneta/enumerable.rb
Overview
Adds the Ruby Enumerable API to the store. The underlying store must support ‘:each_key`.
Instance Attribute Summary
Attributes inherited from Proxy
Instance Method Summary collapse
-
#each ⇒ Object
(also: #each_pair)
Enumerate over all pairs in the store.
-
#initialize(adapter, options = {}) ⇒ Enumerable
constructor
A new instance of Enumerable.
Methods inherited from Proxy
#clear, #close, #config, #create, #delete, #each_key, #features, features_mask, #fetch_values, #increment, #key?, #load, #merge!, not_supports, #slice, #store, #values_at
Methods included from Config
Methods included from Defaults
#[], #[]=, #close, #create, #decrement, #each_key, #features, #fetch, #fetch_values, included, #increment, #key?, #merge!, #slice, #supports?, #update, #values_at
Methods included from OptionSupport
#expires, #prefix, #raw, #with
Constructor Details
#initialize(adapter, options = {}) ⇒ Enumerable
Returns a new instance of Enumerable.
16 17 18 19 |
# File 'lib/moneta/enumerable.rb', line 16 def initialize(adapter, = {}) raise "Adapter must support :each_key" unless adapter.supports? :each_key super end |
Instance Method Details
#each ⇒ Enumerator #each {|pair| ... } ⇒ self Also known as: each_pair
Enumerate over all pairs in the store
30 31 32 33 34 |
# 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 |