Method: Moneta::Defaults#fetch_values
- Defined in:
- lib/moneta/mixins.rb
#fetch_values(*keys, **options) ⇒ Object #fetch_values(*keys, **options) {|key| ... } ⇒ Array<Object, nil>
Note:
Some adapters may implement this method atomically. The default implmentation uses #values_at.
Behaves identically to #values_at except that it accepts an optional block. When supplied, the block will be called successively with each supplied key that is not present in the store. The return value of the block call will be used in place of nil in returned the array of values.
281 282 283 284 285 286 287 288 289 290 291 |
# File 'lib/moneta/mixins.rb', line 281 def fetch_values(*keys, **) values = values_at(*keys, **) return values unless block_given? keys.zip(values).map do |key, value| if value == nil yield key else value end end end |