Class: Origin::Smash
- Inherits:
-
Hash
- Object
- Hash
- Origin::Smash
- Defined in:
- lib/origin/smash.rb
Overview
This is a smart hash for use with options and selectors.
Instance Attribute Summary collapse
-
#aliases ⇒ Object
readonly
Returns the value of attribute aliases.
- #aliases The aliases.(Thealiases.) ⇒ Object readonly
-
#serializers ⇒ Object
readonly
Returns the value of attribute serializers.
- #serializers The serializers.(Theserializers.) ⇒ Object readonly
Instance Method Summary collapse
-
#[](key) ⇒ Object
Get an item from the smart hash by the provided key.
-
#__deep_copy__ ⇒ Smash
Perform a deep copy of the smash.
-
#initialize(aliases = {}, serializers = {}) {|_self| ... } ⇒ Smash
constructor
Initialize the new selector.
Constructor Details
#initialize(aliases = {}, serializers = {}) {|_self| ... } ⇒ Smash
Initialize the new selector.
40 41 42 43 |
# File 'lib/origin/smash.rb', line 40 def initialize(aliases = {}, serializers = {}) @aliases, @serializers = aliases, serializers yield(self) if block_given? end |
Instance Attribute Details
#aliases ⇒ Object (readonly)
Returns the value of attribute aliases.
9 10 11 |
# File 'lib/origin/smash.rb', line 9 def aliases @aliases end |
#aliases The aliases.(Thealiases.) ⇒ Object (readonly)
9 |
# File 'lib/origin/smash.rb', line 9 attr_reader :aliases, :serializers |
#serializers ⇒ Object (readonly)
Returns the value of attribute serializers.
9 10 11 |
# File 'lib/origin/smash.rb', line 9 def serializers @serializers end |
#serializers The serializers.(Theserializers.) ⇒ Object (readonly)
9 |
# File 'lib/origin/smash.rb', line 9 attr_reader :aliases, :serializers |
Instance Method Details
#[](key) ⇒ Object
Get an item from the smart hash by the provided key.
55 56 57 |
# File 'lib/origin/smash.rb', line 55 def [](key) fetch(aliases[key]) { super } end |
#__deep_copy__ ⇒ Smash
Perform a deep copy of the smash.
19 20 21 22 23 24 25 |
# File 'lib/origin/smash.rb', line 19 def __deep_copy__ self.class.new(aliases, serializers) do |copy| each_pair do |key, value| copy.store(key, value.__deep_copy__) end end end |