Sha256: b306793e3cc048c0d7d8a409302abe5a1c3cb795f8a751a5641ade1a4d6f334d

Contents?: true

Size: 801 Bytes

Versions: 14

Compression:

Stored size: 801 Bytes

Contents

# encoding: utf-8
module Mongoid #:nodoc:
  module Criterion #:nodoc:
    # Complex criterion are used when performing operations on symbols to get
    # get a shorthand syntax for where clauses.
    #
    # Example:
    #
    # <tt>{ :field => { "$lt" => "value" } }</tt>
    # becomes:
    # <tt> { :field.lt => "value }</tt>
    class Complex
      attr_accessor :key, :operator

      # Create the new complex criterion.
      def initialize(opts = {})
        @key, @operator = opts[:key], opts[:operator]
      end

      def hash
        [@key, @operator].hash
      end

      def eql?(other)
        self == (other)
      end

      def ==(other)
        return false unless other.is_a?(self.class)
        self.key == other.key && self.operator == other.operator
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 3 rubygems

Version Path
mongoid-braxton-2.0.2 lib/mongoid/criterion/complex.rb
mongoid-2.0.2 lib/mongoid/criterion/complex.rb
mongoid-2.0.1 lib/mongoid/criterion/complex.rb
mongoid-2.0.0 lib/mongoid/criterion/complex.rb
mongoid-2.0.0.rc.8 lib/mongoid/criterion/complex.rb
mongoid-2.0.0.rc.7 lib/mongoid/criterion/complex.rb
stonegao-mongoid-2.0.0.rc.6 lib/mongoid/criterion/complex.rb
mongoid-2.0.0.rc.6 lib/mongoid/criterion/complex.rb
mongoid-2.0.0.rc.5 lib/mongoid/criterion/complex.rb
mongoid-2.0.0.rc.4 lib/mongoid/criterion/complex.rb
mongoid-2.0.0.rc.3 lib/mongoid/criterion/complex.rb
mongoid-2.0.0.rc.2 lib/mongoid/criterion/complex.rb
mongoid-2.0.0.rc.1 lib/mongoid/criterion/complex.rb
mongoid-2.0.0.beta.20 lib/mongoid/criterion/complex.rb