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
-
#aliased_associations ⇒ Object
readonly
Returns the value of attribute aliased_associations.
- #aliased_associations The aliased_associations.(Thealiased_associations.) ⇒ Object readonly
-
#aliases ⇒ Object
readonly
Returns the value of attribute aliases.
- #aliases The aliases.(Thealiases.) ⇒ Object readonly
-
#associations ⇒ Object
readonly
Returns the value of attribute associations.
- #associations The associations.(Theassociations.) ⇒ 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 = {}, associations = {}, aliased_associations = {}) {|_self| ... } ⇒ Smash
constructor
Initialize the new selector.
Constructor Details
#initialize(aliases = {}, serializers = {}, associations = {}, aliased_associations = {}) {|_self| ... } ⇒ Smash
Initialize the new selector.
52 53 54 55 56 57 58 |
# File 'lib/mongoid/criteria/queryable/smash.rb', line 52 def initialize(aliases = {}, serializers = {}, associations = {}, aliased_associations = {}) @aliases = aliases @serializers = serializers @associations = associations @aliased_associations = aliased_associations yield(self) if block_given? end |
Instance Attribute Details
#aliased_associations ⇒ Object (readonly)
Returns the value of attribute aliased_associations.
21 22 23 |
# File 'lib/mongoid/criteria/queryable/smash.rb', line 21 def aliased_associations @aliased_associations end |
#aliased_associations The aliased_associations.(Thealiased_associations.) ⇒ Object (readonly)
21 |
# File 'lib/mongoid/criteria/queryable/smash.rb', line 21 attr_reader :aliased_associations |
#aliases ⇒ Object (readonly)
Returns the value of attribute aliases.
12 13 14 |
# File 'lib/mongoid/criteria/queryable/smash.rb', line 12 def aliases @aliases end |
#aliases The aliases.(Thealiases.) ⇒ Object (readonly)
12 |
# File 'lib/mongoid/criteria/queryable/smash.rb', line 12 attr_reader :aliases |
#associations ⇒ Object (readonly)
Returns the value of attribute associations.
18 19 20 |
# File 'lib/mongoid/criteria/queryable/smash.rb', line 18 def associations @associations end |
#associations The associations.(Theassociations.) ⇒ Object (readonly)
18 |
# File 'lib/mongoid/criteria/queryable/smash.rb', line 18 attr_reader :associations |
#serializers ⇒ Object (readonly)
Returns the value of attribute serializers.
15 16 17 |
# File 'lib/mongoid/criteria/queryable/smash.rb', line 15 def serializers @serializers end |
#serializers The serializers.(Theserializers.) ⇒ Object (readonly)
15 |
# File 'lib/mongoid/criteria/queryable/smash.rb', line 15 attr_reader :serializers |
Instance Method Details
#[](key) ⇒ Object
Get an item from the smart hash by the provided key.
68 69 70 |
# File 'lib/mongoid/criteria/queryable/smash.rb', line 68 def [](key) fetch(aliases[key]) { super } end |
#__deep_copy__ ⇒ Smash
Perform a deep copy of the smash.
29 30 31 32 33 34 35 |
# File 'lib/mongoid/criteria/queryable/smash.rb', line 29 def __deep_copy__ self.class.new(aliases, serializers, associations, aliased_associations) do |copy| each_pair do |key, value| copy.store(key, value.__deep_copy__) end end end |