Module: Flexor::Plugins::FlexKeys::StoreMethods

Defined in:
lib/flexor/plugins/flex_keys.rb

Overview

Instance methods that resolve symbol keys to their alternate-case counterpart before delegating to the underlying store.

Instance Method Summary collapse

Instance Method Details

#[](key) ⇒ Object



12
13
14
# File 'lib/flexor/plugins/flex_keys.rb', line 12

def [](key)
  super(resolve_flex_key(key))
end

#[]=(key, value) ⇒ Object



16
17
18
# File 'lib/flexor/plugins/flex_keys.rb', line 16

def []=(key, value)
  super(resolve_flex_key(key), value)
end

#deconstruct_keys(keys) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/flexor/plugins/flex_keys.rb', line 32

def deconstruct_keys(keys)
  return super if keys.nil?

  keys.each_with_object({}) do |key, hash|
    resolved = resolve_flex_key(key)
    hash[key] = @store[resolved] if @store.key?(resolved)
  end
end

#delete(key) ⇒ Object



24
25
26
# File 'lib/flexor/plugins/flex_keys.rb', line 24

def delete(key)
  super(resolve_flex_key(key))
end

#key?(key) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/flexor/plugins/flex_keys.rb', line 28

def key?(key)
  super(resolve_flex_key(key))
end

#set_raw(key, value) ⇒ Object



20
21
22
# File 'lib/flexor/plugins/flex_keys.rb', line 20

def set_raw(key, value)
  super(resolve_flex_key(key), value)
end