Class: Medusa::Storage::Moneta
- Inherits:
-
Object
- Object
- Medusa::Storage::Moneta
- Extended by:
- Forwardable
- Defined in:
- lib/medusa/storage/moneta.rb
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(name, options = {}) ⇒ Moneta
constructor
A new instance of Moneta.
- #keys ⇒ Object
- #merge!(hash) ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize(name, options = {}) ⇒ Moneta
Returns a new instance of Moneta.
13 14 15 16 |
# File 'lib/medusa/storage/moneta.rb', line 13 def initialize(name, = {}) = { threadsafe: true, prefix: 'medusa' } @moneta = ::Moneta.new(name, .merge()) end |
Instance Method Details
#each ⇒ Object
18 19 20 21 22 23 |
# File 'lib/medusa/storage/moneta.rb', line 18 def each @moneta.each_key do |k| yield k, @moneta.fetch(k) end self end |
#keys ⇒ Object
32 33 34 |
# File 'lib/medusa/storage/moneta.rb', line 32 def keys @moneta.each_key.to_a.sort end |
#merge!(hash) ⇒ Object
36 37 38 39 |
# File 'lib/medusa/storage/moneta.rb', line 36 def merge!(hash) @moneta.merge!(hash) unless hash.empty? self end |
#size ⇒ Object
25 26 27 28 29 30 |
# File 'lib/medusa/storage/moneta.rb', line 25 def size current_size = @moneta.each_key.size return @moneta.each_key.reduce(0) { |size, k| size + 1 } if current_size.nil? return current_size end |