Sha256: 2615c69122963c40970339a12dde53d18d6365bdc969c62d7dfe76ab6bc3f430

Contents?: true

Size: 729 Bytes

Versions: 11

Compression:

Stored size: 729 Bytes

Contents

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

        ActiveSupport::Inflector.inflections do |inflect|
          inflect.singular("address", "address")
          inflect.singular("addresses", "address")
          inflect.irregular("canvas", "canvases")
        end

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

        def invert
          REVERSALS[self]
        end

        def singular?
          singularize == self
        end

        def plural?
          pluralize == self
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
mongoid-0.12.0 lib/mongoid/extensions/string/inflections.rb
mongoid-0.11.9 lib/mongoid/extensions/string/inflections.rb
mongoid-0.11.8 lib/mongoid/extensions/string/inflections.rb
mongoid-0.11.7 lib/mongoid/extensions/string/inflections.rb
mongoid-0.11.6 lib/mongoid/extensions/string/inflections.rb
mongoid-0.11.5 lib/mongoid/extensions/string/inflections.rb
mongoid-0.11.4 lib/mongoid/extensions/string/inflections.rb
mongoid-0.11.3 lib/mongoid/extensions/string/inflections.rb
mongoid-0.11.2 lib/mongoid/extensions/string/inflections.rb
mongoid-0.11.1 lib/mongoid/extensions/string/inflections.rb
mongoid-0.11.0 lib/mongoid/extensions/string/inflections.rb