class Trailblazer::Context::Store::IndifferentAccess
Simple yet indifferently accessible hash store, used as replica in Context::Container
. It maintains cache for multiple hashes (wrapped_options, mutable_options etc).
Public Class Methods
new(hashes)
click to toggle source
# File lib/trailblazer/context/store/indifferent_access.rb, line 11 def initialize(hashes) hashes.each do |hash| hash.each do |key, value| self[key] = value end end end
Public Instance Methods
convert_key(key)
click to toggle source
Override of Hashie::Extensions::IndifferentAccess#convert_key to store keys as Symbol by default instead of String. Why ? We need to pass `ctx` as keyword arguments most of the time.
# File lib/trailblazer/context/store/indifferent_access.rb, line 29 def convert_key(key) return key if Symbol === key String === key ? key.to_sym : key end
indifferent_value(value)
click to toggle source
Override of Hashie::Extensions::IndifferentAccess#indifferent_value to not do deep indifferent access conversion. DISCUSS: Should we make this configurable ?
# File lib/trailblazer/context/store/indifferent_access.rb, line 22 def indifferent_value(value) value end