Module: Adapter::Defaults

Defined in:
lib/adapter/defaults.rb

Instance Method Summary collapse

Instance Method Details

#fetch(key, default_attributes = nil, options = nil) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/adapter/defaults.rb', line 3

def fetch(key, default_attributes=nil, options = nil)
  read(key, options) || begin
    if block_given?
      yield(key)
    else
      default_attributes
    end
  end
end

#key?(key, options = nil) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/adapter/defaults.rb', line 19

def key?(key, options = nil)
  !read(key, options).nil?
end

#read_multiple(keys, options = nil) ⇒ Object



13
14
15
16
17
# File 'lib/adapter/defaults.rb', line 13

def read_multiple(keys, options = nil)
  result = {}
  keys.each { |key| result[key] = read(key, options) }
  result
end