Module: Moneta::NilValues Private

Included in:
Adapters::DataMapper, Adapters::Memory, Adapters::PStore
Defined in:
lib/moneta/nil_values.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 contains overrides of methods in Defaults where additional nil checks are required, because nil values are possible in the store.

Instance Method Summary collapse

Instance Method Details

#fetch_values(*keys, **options) ⇒ 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.



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/moneta/nil_values.rb', line 6

def fetch_values(*keys, **options)
  values = values_at(*keys, **options)
  return values unless block_given?
  keys.zip(values).map do |key, value|
    if value == nil && !key?(key)
      yield key
    else
      value
    end
  end
end

#merge!(pairs, options = {}) ⇒ 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.



24
25
26
27
28
29
30
31
32
33
# File 'lib/moneta/nil_values.rb', line 24

def merge!(pairs, options = {})
  pairs.each do |key, value|
    if block_given? && key?(key, options)
      existing = load(key, options)
      value = yield(key, existing, value)
    end
    store(key, value, options)
  end
  self
end

#slice(*keys, **options) ⇒ 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.



18
19
20
21
22
# File 'lib/moneta/nil_values.rb', line 18

def slice(*keys, **options)
  keys.zip(values_at(*keys, **options)).reject do |key, value|
    value == nil && !key?(key)
  end
end