Class: Mongoid::Criteria::Queryable::Smash
- Inherits:
-
Hash
- Object
- Hash
- Mongoid::Criteria::Queryable::Smash
- Defined in:
- lib/mongoid/criteria/queryable/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.
44 45 46 47 |
# File 'lib/mongoid/criteria/queryable/smash.rb', line 44 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.
13 14 15 |
# File 'lib/mongoid/criteria/queryable/smash.rb', line 13 def aliases @aliases end |
#aliases The aliases.(Thealiases.) ⇒ Object (readonly)
13 |
# File 'lib/mongoid/criteria/queryable/smash.rb', line 13 attr_reader :aliases, :serializers |
#serializers ⇒ Object (readonly)
Returns the value of attribute serializers.
13 14 15 |
# File 'lib/mongoid/criteria/queryable/smash.rb', line 13 def serializers @serializers end |
#serializers The serializers.(Theserializers.) ⇒ Object (readonly)
13 |
# File 'lib/mongoid/criteria/queryable/smash.rb', line 13 attr_reader :aliases, :serializers |
Instance Method Details
#[](key) ⇒ Object
Get an item from the smart hash by the provided key.
59 60 61 |
# File 'lib/mongoid/criteria/queryable/smash.rb', line 59 def [](key) fetch(aliases[key]) { super } end |
#__deep_copy__ ⇒ Smash
Perform a deep copy of the smash.
23 24 25 26 27 28 29 |
# File 'lib/mongoid/criteria/queryable/smash.rb', line 23 def __deep_copy__ self.class.new(aliases, serializers) do |copy| each_pair do |key, value| copy.store(key, value.__deep_copy__) end end end |