Sha256: 5436198e72eedbee8a99d34bf7f04948edecbe95afaffa6f71f4eed2cb1c8f3c

Contents?: true

Size: 837 Bytes

Versions: 171

Compression:

Stored size: 837 Bytes

Contents

# encoding: utf-8
module Mongoid #:nodoc:
  module Extensions #:nodoc:
    module Object #:nodoc:

      # This module has object checks in it.
      module Checks #:nodoc:

        # Since Active Support's blank? check looks to see if the object
        # responds to #empty? and will call it if it does, we need another way
        # to check if the object is empty or nil in case the user has defined a
        # field called "empty" on the document.
        #
        # @example Is the array vacant?
        #   [].vacant?
        #
        # @example Is the object vacant?
        #   nil.vacant?
        #
        # @return [ true, false ] True if empty or nil, false if not.
        #
        # @since 2.0.2
        def _vacant?
          is_a?(::Array) || is_a?(::String) ? empty? : !self
        end
      end
    end
  end
end

Version data entries

171 entries across 79 versions & 4 rubygems

Version Path
classiccms-0.5.16 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/extensions/object/checks.rb
classiccms-0.5.15 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/extensions/object/checks.rb
classiccms-0.5.15 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/extensions/object/checks.rb
classiccms-0.5.15 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/extensions/object/checks.rb
classiccms-0.5.14 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/extensions/object/checks.rb
classiccms-0.5.14 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/extensions/object/checks.rb
classiccms-0.5.14 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/extensions/object/checks.rb
classiccms-0.5.13 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/extensions/object/checks.rb
classiccms-0.5.13 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/extensions/object/checks.rb
classiccms-0.5.13 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/extensions/object/checks.rb
mongoid-2.5.0 lib/mongoid/extensions/object/checks.rb
classiccms-0.5.12 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/extensions/object/checks.rb
classiccms-0.5.12 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/extensions/object/checks.rb
classiccms-0.5.12 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/extensions/object/checks.rb
classiccms-0.5.11 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/extensions/object/checks.rb
classiccms-0.5.11 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/extensions/object/checks.rb
classiccms-0.5.11 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/extensions/object/checks.rb
classiccms-0.5.10 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/extensions/object/checks.rb
classiccms-0.5.10 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/extensions/object/checks.rb
classiccms-0.5.10 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/extensions/object/checks.rb