Module: Moneta::NilValues Private

Included in:
Adapters::DataMapper, Adapters::Memory, Adapters::PStore
Defined in:
lib/moneta/mixins.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.



375
376
377
378
379
380
381
382
383
384
385
# File 'lib/moneta/mixins.rb', line 375

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.



393
394
395
396
397
398
399
400
401
402
# File 'lib/moneta/mixins.rb', line 393

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.



387
388
389
390
391
# File 'lib/moneta/mixins.rb', line 387

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