Module: Moneta::EachKeySupport Private
- Included in:
- Adapters::DBM, Adapters::Daybreak, Adapters::GDBM, Adapters::LevelDB, Adapters::Memory, Adapters::SDBM, Adapters::TDB, Adapters::TokyoCabinet
- Defined in:
- lib/moneta/each_key_support.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
This provides an each_key implementation that works in most cases.
Class Method Summary collapse
- .included(base) ⇒ Object private
Instance Method Summary collapse
- #each_key ⇒ Object private
Class Method Details
.included(base) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
23 24 25 |
# File 'lib/moneta/each_key_support.rb', line 23 def self.included(base) base.supports(:each_key) if base.respond_to?(:supports) end |
Instance Method Details
#each_key ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/moneta/each_key_support.rb', line 5 def each_key return enum_for(:each_key) unless block_given? if @backend.respond_to?(:each_key) @backend.each_key { |key| yield key } elsif @backend.respond_to?(:keys) if keys = @backend.keys keys.each { |key| yield key } end elsif @backend.respond_to?(:each) @backend.each { |key, _| yield key } else raise ::NotImplementedError, "No enumerable found on backend" end self end |