Module: Origin::Queryable
- Includes:
- Aggregable, Mergeable, 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.
Constant Summary
Constants included from Selectable
Selectable::LINE_STRING, Selectable::POINT, Selectable::POLYGON
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 Aggregable
#aggregating, #aggregating Flag for whether or not we are aggregating., #pipeline, #pipeline The aggregation pipeline.
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 = :mongo) {|_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, #collation, #comment, #cursor_type, #descending, forwardables, #hint, #limit, #max_scan, #no_timeout, #only, #order_by, #reorder, #skip, #slice, #snapshot, #without
Methods included from Macroable
Methods included from Selectable
#all, #and, #between, #elem_match, #exists, forwardables, #geo_spacial, #gt, #gte, #in, #lt, #lte, #max_distance, #mod, #ne, #near, #near_sphere, #negating?, #nin, #nor, #not, #or, #text_search, #where, #with_size, #with_type
Methods included from Aggregable
#aggregating?, #group, #project, #unwind
Methods included from Mergeable
#intersect, #override, #reset_strategies!, #union
Instance Attribute Details
#aliases ⇒ Object (readonly)
Returns the value of attribute aliases.
32 33 34 |
# File 'lib/origin/queryable.rb', line 32 def aliases @aliases end |
#aliases The aliases.(Thealiases.) ⇒ Object (readonly)
32 |
# File 'lib/origin/queryable.rb', line 32 attr_reader :aliases, :driver, :serializers |
#driver ⇒ Object (readonly)
Returns the value of attribute driver.
32 33 34 |
# File 'lib/origin/queryable.rb', line 32 def driver @driver end |
#driver The Mongo driver being used.(TheMongodriverbeingused.) ⇒ Object (readonly)
32 |
# File 'lib/origin/queryable.rb', line 32 attr_reader :aliases, :driver, :serializers |
#serializers ⇒ Object (readonly)
Returns the value of attribute serializers.
32 33 34 |
# File 'lib/origin/queryable.rb', line 32 def serializers @serializers end |
#serializers The serializers.(Theserializers.) ⇒ Object (readonly)
32 |
# File 'lib/origin/queryable.rb', line 32 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.
45 46 47 48 |
# File 'lib/origin/queryable.rb', line 45 def ==(other) return false unless other.is_a?(Queryable) selector == other.selector && == other. end |
#initialize(aliases = {}, serializers = {}, driver = :mongo) {|_self| ... } ⇒ Object
Initialize the new queryable. Will yield itself to the block if a block is provided for objects that need additional behaviour.
61 62 63 64 65 66 67 |
# File 'lib/origin/queryable.rb', line 61 def initialize(aliases = {}, serializers = {}, driver = :mongo) @aliases, @driver, @serializers = aliases, driver.to_sym, serializers @options = Options.new(aliases, serializers) @selector = Selector.new(aliases, serializers) @pipeline = Pipeline.new(aliases) yield(self) if block_given? end |
#initialize_copy(other) ⇒ Object
Handle the creation of a copy via #clone or #dup.
77 78 79 80 81 |
# File 'lib/origin/queryable.rb', line 77 def initialize_copy(other) @options = other..__deep_copy__ @selector = other.selector.__deep_copy__ @pipeline = other.pipeline.__deep_copy__ end |