模块:Mongoid::Equality
Overview
该模块包含 Mongoid 的 document 克隆/复制行为。
在命名空间下定义
模块: 类方法
实例方法摘要折叠
-
# <=> (other) ⇒ 整数
默认通过string 的ID 版本进行比较。
-
# == (other) ⇒ true | false
对文档ID 执行相等性检查。
-
# eql? (其他)→ true | false
委托给 ==。
实例方法详细信息
# <=> (other) ⇒整数
默认通过string 的ID 版本进行比较。
18 19 20 21 22 |
# File 'lib/mongoid/equality.rb', 第18行 def <=>(其他) return 超 除非 其他.is_a?(Mongoid::相等) 属性['_id'].to_s <=> 其他.属性['_id'].to_s end |
# == (other) ⇒ true | false
对文档ID 执行相等性检查。 要进行更强大的相等性检查,请重写此方法。
33 34 35 36 |
# File 'lib/mongoid/equality.rb', 第33行 def ==(其他) self.class == 其他.class && 属性['_id'] == 其他.属性['_id'] end |
# eql? (其他)→ true | false
委托给 ==。 在需要检查哈希值时使用。
46 47 48 |
# File 'lib/mongoid/equality.rb', 第46行 def eql?(其他) self == 其他 end |