Sha256: 23bf2feb75a047a984291903b9d1b556a113deb21ddf4b2d35d1e85b7745e135
Contents?: true
Size: 958 Bytes
Versions: 1
Compression:
Stored size: 958 Bytes
Contents
module Trailblazer class Context module Aliasing def initialize(wrapped_options, mutable_options, context_alias: {}, **) super(wrapped_options, mutable_options) @aliases = context_alias.invert end def [](key) return super unless (aka = @aliases[key]) # yepp, nil/false won't work super(aka) end def key?(key) return super unless (aka = @aliases[key]) # yepp, nil/false won't work super(aka) end # @private ? def merge(hash) original, mutable_options = decompose self.class.new( original, mutable_options.merge(hash), context_alias: @aliases.invert # DISCUSS: maybe we can speed up by remembering the original options? ) end def to_hash super.merge(Hash[@aliases.collect { |aka, k| key?(k) ? [aka, self[k]] : nil }.compact]) # FIXME: performance! end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
trailblazer-context-0.3.0 | lib/trailblazer/context/aliasing.rb |