模块:Mongoid::Extensions::Hash::ClassMethods

定义于:
lib/mongoid/extensions/hash.rb

实例方法摘要折叠

实例方法详细信息

# mongoize (对象) ⇒哈希| nil

将对象从我们处理的Ruby类型转换为mongo友好类型。

例子:

将对象 Mongoize。

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

参数:

  • 对象 ( Object )

    要 mongoize 的对象。

返回:

  • ( Hash | nil )

    对象mongoized 或 nil。



123
124
125
126
127
128
129
130
131
# File 'lib/mongoid/extensions/hash.rb', line 123

def mongoize(对象)
  return if 对象.nil?
  案例 对象
  when BSON::文档
    对象.dup.transform_values!(:mongoize)
  when 哈希
    BSON::文档.new(对象.transform_values(:mongoize))
  end
end

#可调整大小?true

这个对象的大小可以改变吗?

例子:

哈希大小是否可调整?

{}.resizable?

返回:

  • ( true )

    true。



139
140
141
# File 'lib/mongoid/extensions/hash.rb', line 139

def 可调整大小?
  true
end