模块:Mongoid::Extensions::Set::ClassMethods

定义于:
lib/mongoid/extensions/ 设立.rb

实例方法摘要折叠

实例方法详细信息

# demogoize (object) ⇒设置

将对象从其 mongo 友好的 Ruby 类型转换为此类型。

例子:

将对象去妖化。

Set.demongoize([1, 2, 3])

参数:

  • 对象 ( Array )

    要去妖化的对象。

返回:

  • ()

    设立.



39
40
41
42
43
44
# File 'lib/mongoid/extensions/ 设立.rb', line 39

def demogoize(对象)
  案例 对象
  when :: then 对象
  when ::阵列 then ::.new(对象)
  end
end

# mongoize (对象) ⇒数组| nil

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

例子:

将对象 Mongoize。

Set.mongoize(Set.new([1,2,3]))

参数:

  • 对象 ()

    要 mongoize 的对象。

返回:

  • ( Array | nil )

    对象mongoized 或 nil。



55
56
57
58
59
60
61
# File 'lib/mongoid/extensions/ 设立.rb', line 55

def mongoize(对象)
  return if 对象.nil?
  案例 对象
  when :: then ::阵列.mongoize(对象.to_a).uniq
  when ::阵列 then ::阵列.mongoize(对象).uniq
  end
end