The selector is a special kind of hash that knows how to serialize values coming into it as well as being alias and locale aware for key names.
Merges another selector into this one.
@example Merge in another selector.
selector.merge!(name: "test")
@param [ Hash, Selector ] other The object to merge in.
@return [ Selector ] The selector.
@since 1.0.0
# File lib/origin/selector.rb, line 17 def merge!(other) other.each_pair do |key, value| if value.is_a?(Hash) && self[key.to_s].is_a?(Hash) value = self[key.to_s].merge(value) end if multi_selection?(key) value = (self[key.to_s] || []).concat(value) end store(key, value) end end
Store the value in the selector for the provided key. The selector will handle all necessary serialization and localization in this step.
@example Store a value in the selector.
selector.store(:key, "testing")
@param [ String, Symbol ] key The name of the attribute. @param [ Object ] value The value to add.
@return [ Object ] The stored object.
@since 1.0.0
# File lib/origin/selector.rb, line 41 def store(key, value) name, serializer = storage_pair(key) if multi_selection?(name) super(name, evolve_multi(value)) else super(normalized_key(name, serializer), evolve(serializer, value)) end end