Sha256: 670d6fe2b229d671c4e8d51772decad9f835074fe632c7f455f2ac4dc6ec8b14
Contents?: true
Size: 1.11 KB
Versions: 1
Compression:
Stored size: 1.11 KB
Contents
require "hashie" module Trailblazer module Context module Store # Simple yet indifferently accessible hash store, used as replica in Context::Container. # It maintains cache for multiple hashes (wrapped_options, mutable_options etc). class IndifferentAccess < Hash include Hashie::Extensions::IndifferentAccess def initialize(hashes) hashes.each do |hash| hash.each do |key, value| self[key] = value end end end # Override of Hashie::Extensions::IndifferentAccess#indifferent_value # to not do deep indifferent access conversion. # DISCUSS: Should we make this configurable ? def indifferent_value(value) value end # 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. def convert_key(key) return key if Symbol === key String === key ? key.to_sym : key end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
trailblazer-context-0.3.2 | lib/trailblazer/context/store/indifferent_access.rb |