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
mongo_doc-0.6.34 lib/mongoid/extensions/symbol/inflections.rb
mongo_doc-0.6.33 lib/mongoid/extensions/symbol/inflections.rb
mongo_doc-0.6.32 lib/mongoid/extensions/symbol/inflections.rb
mongo_doc-0.6.31 lib/mongoid/extensions/symbol/inflections.rb
mongo_doc-0.6.30 lib/mongoid/extensions/symbol/inflections.rb
mongo_doc-0.6.29 lib/mongoid/extensions/symbol/inflections.rb
mongo_doc-0.6.28 lib/mongoid/extensions/symbol/inflections.rb
mongo_doc-0.6.27 lib/mongoid/extensions/symbol/inflections.rb
mongo_doc-0.6.26 lib/mongoid/extensions/symbol/inflections.rb
mongo_doc-0.6.25 lib/mongoid/extensions/symbol/inflections.rb
mongo_doc-0.6.23 lib/mongoid/extensions/symbol/inflections.rb
mongo_doc-0.6.22 lib/mongoid/extensions/symbol/inflections.rb
mongo_doc-0.6.21 lib/mongoid/extensions/symbol/inflections.rb
mongo_doc-0.6.20 lib/mongoid/extensions/symbol/inflections.rb
mongo_doc-0.6.19 lib/mongoid/extensions/symbol/inflections.rb
mongo_doc-0.6.18 lib/mongoid/extensions/symbol/inflections.rb
mongo_doc-0.6.17 lib/mongoid/extensions/symbol/inflections.rb
mongo_doc-0.6.16 lib/mongoid/extensions/symbol/inflections.rb
mongo_doc-0.6.15 lib/mongoid/extensions/symbol/inflections.rb
mongo_doc-0.6.14 lib/mongoid/extensions/symbol/inflections.rb