Sha256: fac192291a67a209615bebb04a93079660ed498aa804a7aa5c60a21aea49e3f7

Contents?: true

Size: 773 Bytes

Versions: 63

Compression:

Stored size: 773 Bytes

Contents

# encoding: utf-8
module Mongoid #:nodoc:
  module Extensions #:nodoc:
    module Symbol #:nodoc:
      module Inflections #:nodoc:

        REVERSALS = {
          :asc => :desc,
          :ascending => :descending,
          :desc => :asc,
          :descending => :ascending
        }

        def invert
          REVERSALS[self]
        end

        def singular?
          to_s.singular?
        end

        def plural?
          to_s.plural?
        end

        ["gt", "lt", "gte", "lte", "ne", "in", "nin", "mod", "all", "size", "exists"].each do |oper|
          class_eval <<-OPERATORS
            def #{oper}
              Criterion::Complex.new(:key => self, :operator => "#{oper}")
            end
          OPERATORS
        end
      end
    end
  end
end

Version data entries

63 entries across 63 versions & 5 rubygems

Version Path
mongoid-1.2.1 lib/mongoid/extensions/symbol/inflections.rb
mongoid-1.2.0 lib/mongoid/extensions/symbol/inflections.rb
mongoid-1.1.4 lib/mongoid/extensions/symbol/inflections.rb