module Mongoid::Extensions::Hash::ClassMethods

Public Instance Methods

mongoize(object) click to toggle source

Turn the object from the ruby type we deal with to a Mongo friendly type.

@example Mongoize the object.

Hash.mongoize([ 1, 2, 3 ])

@param [ Object ] object The object to mongoize.

@return [ Hash | nil ] The object mongoized or nil.

# File lib/mongoid/extensions/hash.rb, line 123
def mongoize(object)
  return if object.nil?
  case object
  when BSON::Document
    object.dup.transform_values!(&:mongoize)
  when Hash
    BSON::Document.new(object.transform_values(&:mongoize))
  end
end
resizable?() click to toggle source

Can the size of this object change?

@example Is the hash resizable?

{}.resizable?

@return [ true ] true.

# File lib/mongoid/extensions/hash.rb, line 139
def resizable?
  true
end