Module: Adapter::Defaults
- Defined in:
- lib/adapter/defaults.rb
Instance Method Summary collapse
- #decode(attributes) ⇒ Object
- #encode(attributes) ⇒ Object
- #fetch(key, default_attributes = nil) ⇒ Object
- #key?(key) ⇒ Boolean
- #key_for(key) ⇒ Object
- #read_multiple(*keys) ⇒ Object
Instance Method Details
#decode(attributes) ⇒ Object
31 32 33 |
# File 'lib/adapter/defaults.rb', line 31 def decode(attributes) attributes end |
#encode(attributes) ⇒ Object
27 28 29 |
# File 'lib/adapter/defaults.rb', line 27 def encode(attributes) attributes end |
#fetch(key, default_attributes = nil) ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/adapter/defaults.rb', line 3 def fetch(key, default_attributes=nil) read(key) || begin if block_given? yield(key) else default_attributes end end end |
#key?(key) ⇒ Boolean
19 20 21 |
# File 'lib/adapter/defaults.rb', line 19 def key?(key) !read(key).nil? end |
#key_for(key) ⇒ Object
23 24 25 |
# File 'lib/adapter/defaults.rb', line 23 def key_for(key) key end |
#read_multiple(*keys) ⇒ Object
13 14 15 16 17 |
# File 'lib/adapter/defaults.rb', line 13 def read_multiple(*keys) result = {} keys.each { |key| result[key_for(key)] = read(key) } result end |