Module: Mongoid::Criteria::Queryable

Includes:
Aggregable, Expandable, Mergeable, Optional, Storable, Selectable
Included in:
Mongoid::Criteria
Defined in:
build/mongoid-master/lib/mongoid/criteria/queryable.rb,
build/mongoid-master/lib/mongoid/criteria/queryable/key.rb,
build/mongoid-master/lib/mongoid/criteria/queryable/smash.rb,
build/mongoid-master/lib/mongoid/criteria/queryable/options.rb,
build/mongoid-master/lib/mongoid/criteria/queryable/optional.rb,
build/mongoid-master/lib/mongoid/criteria/queryable/pipeline.rb,
build/mongoid-master/lib/mongoid/criteria/queryable/selector.rb,
build/mongoid-master/lib/mongoid/criteria/queryable/storable.rb,
build/mongoid-master/lib/mongoid/criteria/queryable/macroable.rb,
build/mongoid-master/lib/mongoid/criteria/queryable/mergeable.rb,
build/mongoid-master/lib/mongoid/criteria/queryable/aggregable.rb,
build/mongoid-master/lib/mongoid/criteria/queryable/expandable.rb,
build/mongoid-master/lib/mongoid/criteria/queryable/selectable.rb,
build/mongoid-master/lib/mongoid/criteria/queryable/extensions/set.rb,
build/mongoid-master/lib/mongoid/criteria/queryable/extensions/date.rb,
build/mongoid-master/lib/mongoid/criteria/queryable/extensions/hash.rb,
build/mongoid-master/lib/mongoid/criteria/queryable/extensions/time.rb,
build/mongoid-master/lib/mongoid/criteria/queryable/extensions/array.rb,
build/mongoid-master/lib/mongoid/criteria/queryable/extensions/range.rb,
build/mongoid-master/lib/mongoid/criteria/queryable/extensions/object.rb,
build/mongoid-master/lib/mongoid/criteria/queryable/extensions/regexp.rb,
build/mongoid-master/lib/mongoid/criteria/queryable/extensions/string.rb,
build/mongoid-master/lib/mongoid/criteria/queryable/extensions/symbol.rb,
build/mongoid-master/lib/mongoid/criteria/queryable/extensions/boolean.rb,
build/mongoid-master/lib/mongoid/criteria/queryable/extensions/numeric.rb,
build/mongoid-master/lib/mongoid/criteria/queryable/extensions/date_time.rb,
build/mongoid-master/lib/mongoid/criteria/queryable/extensions/nil_class.rb,
build/mongoid-master/lib/mongoid/criteria/queryable/extensions/big_decimal.rb,
build/mongoid-master/lib/mongoid/criteria/queryable/extensions/time_with_zone.rb

Overview

A queryable is any object that needs queryable’s dsl injected into it to build MongoDB queries. For example, a Mongoid::Criteria is an Queryable.

Examples:

Include queryable functionality.

class Criteria
  include Queryable
end

Defined Under Namespace

Modules: Aggregable, Expandable, Extensions, Macroable, Mergeable, Optional, Selectable, Storable Classes: Key, Options, Pipeline, Selector, Smash

Instance Attribute Summary collapse

Attributes included from Optional

#options, #options The query options.

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

Methods included from Optional

#ascending, #batch_size, #collation, #comment, #cursor_type, #descending, forwardables, #hint, #limit, #max_scan, #max_time_ms, #no_timeout, #only, #order_by, #reorder, #skip, #slice, #snapshot, #without

Methods included from Macroable

#key

Methods included from Selectable

#atomic_selector

Methods included from Aggregable

#aggregating?, #group, #project, #unwind

Methods included from Mergeable

#and_with_operator, #intersect, #override, #reset_strategies!, #union

Methods included from Storable

#add_field_expression, #add_logical_operator_expression, #add_one_expression, #add_operator_expression

Instance Attribute Details

#aliasesObject (readonly)

Returns the value of attribute aliases.



36
37
38
# File 'build/mongoid-master/lib/mongoid/criteria/queryable.rb', line 36

def aliases
  @aliases
end

#aliases The aliases.(Thealiases.) ⇒ Object (readonly)



36
# File 'build/mongoid-master/lib/mongoid/criteria/queryable.rb', line 36

attr_reader :aliases

#serializersObject (readonly)

Returns the value of attribute serializers.



39
40
41
# File 'build/mongoid-master/lib/mongoid/criteria/queryable.rb', line 39

def serializers
  @serializers
end

#serializers The serializers.(Theserializers.) ⇒ Object (readonly)



39
# File 'build/mongoid-master/lib/mongoid/criteria/queryable.rb', line 39

attr_reader :serializers

Instance Method Details

#==(other) ⇒ true | false

Is this queryable equal to another object? Is true if the selector and options are equal.

Examples:

Are the objects equal?

queryable == criteria

Parameters:

  • other (Object)

    The object to compare against.

Returns:

  • (true | false)

    If the objects are equal.



50
51
52
53
# File 'build/mongoid-master/lib/mongoid/criteria/queryable.rb', line 50

def ==(other)
  return false unless other.is_a?(Queryable)
  selector == other.selector && options == other.options
end

#initialize(aliases = {}, serializers = {}, associations = {}, aliased_associations = {}) {|_self| ... } ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize the new queryable. Will yield itself to the block if a block is provided for objects that need additional behavior.

Examples:

Initialize the queryable.

Queryable.new

Parameters:

  • aliases (Hash) (defaults to: {})

    The optional field aliases.

  • serializers (Hash) (defaults to: {})

    The optional field serializers.

  • associations (Hash) (defaults to: {})

    The optional associations.

  • aliased_associations (Hash) (defaults to: {})

    The optional aliased associations.

  • driver (Symbol)

    The driver being used.

Yields:

  • (_self)

Yield Parameters:



68
69
70
71
72
73
74
75
# File 'build/mongoid-master/lib/mongoid/criteria/queryable.rb', line 68

def initialize(aliases = {}, serializers = {}, associations = {}, aliased_associations = {})
  @aliases, @serializers = aliases, serializers
  @options = Options.new(aliases, serializers, associations, aliased_associations)
  @selector = Selector.new(aliases, serializers, associations, aliased_associations)
  @pipeline = Pipeline.new(aliases)
  @aggregating = nil
  yield(self) if block_given?
end

#initialize_copy(other) ⇒ Object

Handle the creation of a copy via #clone or #dup.

Examples:

Handle copy initialization.

queryable.initialize_copy(criteria)

Parameters:



83
84
85
86
87
# File 'build/mongoid-master/lib/mongoid/criteria/queryable.rb', line 83

def initialize_copy(other)
  @options = other.options.__deep_copy__
  @selector = other.selector.__deep_copy__
  @pipeline = other.pipeline.__deep_copy__
end