模块:Mongoid::Association::Nested::Buildable
Overview
Mixin 模块,包含用于对关联执行 #accepts_nested_attributes_for 属性分配的常用功能。
实例属性摘要折叠
-
#关联⇒ 对象
返回属性关联的值。
-
#属性"> 对象
返回属性(attribute)的值。
-
# existing ⇒ 对象
返回现有属性的值。
-
# options ⇒ 对象
返回属性选项的值。
实例方法摘要折叠
-
# allow_destroy? ⇒ true | false
确定是否允许销毁此文档。
-
# convert_id (klass, ID ) ⇒ BSON::ObjectId | string |对象
将ID转换为其适当的类型。
-
#拒绝? (文档, attrs) ⇒ true | false
如果使用宏定义选项,则返回拒绝。
-
# update_only? ⇒ true | false
确定是否只能进行更新。
实例属性详细信息
#关联⇒对象
返回属性关联的值。
13 14 15 |
# File 'lib/mongoid/association/nested/nested_buildable.rb', line 13 def 关联 @association end |
#属性">对象
返回属性(attribute)的值。
13 14 15 |
# File 'lib/mongoid/association/nested/nested_buildable.rb', line 13 def 属性 @attributes end |
# existing ⇒对象
返回现有属性的值。
13 14 15 |
# File 'lib/mongoid/association/nested/nested_buildable.rb', line 13 def 现有的 @existing end |
# options ⇒对象
返回属性选项的值。
13 14 15 |
# File 'lib/mongoid/association/nested/nested_buildable.rb', line 13 def @options end |
实例方法详细信息
# allow_destroy? ⇒ true | false
确定是否允许销毁此文档。
21 22 23 |
# File 'lib/mongoid/association/nested/nested_buildable.rb', line 21 def allow_destroy? [:allow_destroy] || false end |
# convert_id (klass, ID ) ⇒ BSON::ObjectId | string |对象
将ID转换为其适当的类型。
65 66 67 |
# File 'lib/mongoid/association/nested/nested_buildable.rb', line 65 def convert_id(klass, id) klass.using_object_id? ? BSON::ObjectId.mongoize(id) : id end |
#拒绝? (文档, attrs) ⇒ true | false
如果使用宏定义选项,则返回拒绝。
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/mongoid/association/nested/nested_buildable.rb', line 34 def 拒绝?(文档, attrs) 案例 callback = [:reject_if] when 符号 文档.方法(callback).元数 == 0 ? 文档.发送(callback) : 文档.发送(callback, attrs) when Proc callback.调用(attrs) else false end end |
# update_only? ⇒ true | false
确定是否只能进行更新。 仅对一对一关联有效。
52 53 54 |
# File 'lib/mongoid/association/nested/nested_buildable.rb', line 52 def update_only? [:update_only] || false end |