Module: Origin::Queryable
- Includes:
- Optional, Selectable
- Defined in:
- lib/origin/queryable.rb
Overview
A queryable is any object that needs origin’s dsl injected into it to build MongoDB queries. For example, a Mongoid::Criteria is an Origin::Queryable.
Instance Attribute Summary collapse
-
#aliases ⇒ Object
readonly
Returns the value of attribute aliases.
- #aliases The aliases.(Thealiases.) ⇒ Object readonly
-
#driver ⇒ Object
readonly
Returns the value of attribute driver.
- #driver The Mongo driver being used.(TheMongodriverbeingused.) ⇒ Object readonly
-
#serializers ⇒ Object
readonly
Returns the value of attribute serializers.
- #serializers The serializers.(Theserializers.) ⇒ Object readonly
Attributes included from Optional
#options, #options The query options.
Attributes included from Selectable
#negating, #negating If the next spression is negated., #selector, #selector The query selector.
Attributes included from Mergeable
#strategy, #strategy The name of the current strategy.
Instance Method Summary collapse
-
#==(other) ⇒ true, false
Is this queryable equal to another object? Is true if the selector and options are equal.
-
#initialize(aliases = {}, serializers = {}, driver = :moped) {|_self| ... } ⇒ Object
Initialize the new queryable.
-
#initialize_copy(other) ⇒ Object
Handle the creation of a copy via #clone or #dup.
Methods included from Optional
#ascending, #batch_size, #descending, forwardables, #hint, #limit, #max_scan, #no_timeout, #only, #order_by, #skip, #slice, #snapshot, #without
Methods included from Macroable
Methods included from Selectable
#all, #and, #between, #elem_match, #exists, forwardables, #gt, #gte, #in, #lt, #lte, #max_distance, #mod, #ne, #near, #near_sphere, #negating?, #nin, #nor, #not, #or, #where, #with_size, #with_type, #within_box, #within_circle, #within_polygon, #within_spherical_circle
Methods included from Mergeable
#intersect, #override, #reset_strategies!, #union
Instance Attribute Details
#aliases ⇒ Object (readonly)
Returns the value of attribute aliases.
28 29 30 |
# File 'lib/origin/queryable.rb', line 28 def aliases @aliases end |
#aliases The aliases.(Thealiases.) ⇒ Object (readonly)
28 |
# File 'lib/origin/queryable.rb', line 28 attr_reader :aliases, :driver, :serializers |
#driver ⇒ Object (readonly)
Returns the value of attribute driver.
28 29 30 |
# File 'lib/origin/queryable.rb', line 28 def driver @driver end |
#driver The Mongo driver being used.(TheMongodriverbeingused.) ⇒ Object (readonly)
28 |
# File 'lib/origin/queryable.rb', line 28 attr_reader :aliases, :driver, :serializers |
#serializers ⇒ Object (readonly)
Returns the value of attribute serializers.
28 29 30 |
# File 'lib/origin/queryable.rb', line 28 def serializers @serializers end |
#serializers The serializers.(Theserializers.) ⇒ Object (readonly)
28 |
# File 'lib/origin/queryable.rb', line 28 attr_reader :aliases, :driver, :serializers |
Instance Method Details
#==(other) ⇒ true, false
Is this queryable equal to another object? Is true if the selector and options are equal.
41 42 43 44 |
# File 'lib/origin/queryable.rb', line 41 def ==(other) return false unless other.is_a?(Queryable) selector == other.selector && == other. end |
#initialize(aliases = {}, serializers = {}, driver = :moped) {|_self| ... } ⇒ Object
Initialize the new queryable. Will yield itself to the block if a block is provided for objects that need additional behaviour.
57 58 59 60 61 62 |
# File 'lib/origin/queryable.rb', line 57 def initialize(aliases = {}, serializers = {}, driver = :moped) @aliases, @driver, @serializers = aliases, driver.to_sym, serializers @options, @selector = Options.new(aliases, serializers), Selector.new(aliases, serializers) yield(self) if block_given? end |
#initialize_copy(other) ⇒ Object
Handle the creation of a copy via #clone or #dup.
72 73 74 75 |
# File 'lib/origin/queryable.rb', line 72 def initialize_copy(other) @options = other..__deep_copy__ @selector = other.selector.__deep_copy__ end |