模块:Mongoid::Attributes::Processing

包含在:
Mongoid::Attributes
定义于:
lib/mongoid/attributes/ 处理

Overview

该模块包含处理属性的行为。

实例方法摘要折叠

实例方法详细信息

# process_attributes (attrs = nil) {|_self| ... } ⇒对象

如果文档中存在这些属性的字段,则处理提供的属性,将其转换为正确的值。 这将仅限于所提供的Hash中提供的属性,以便不会将额外的nil 值放入文档的属性中。

例子:

处理属性。

person.process_attributes(:title => "sir", :age => 40)

参数:

  • attrs 哈希 (默认为: nil

    要设立的属性。

产量:

  • ( _self )

收益参数:



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/mongoid/attributes/ 处理', line 16

def process_attributes(attrs = nil)
  attrs ||= {}
  除非 attrs.空?
    attrs = sanitize_for_mass_signment(attrs)
    attrs.each_pair do |key, |
      来年 if 待处理属性?(key, )

      process_attribute(key, )
    end
  end
  产量 self if block_given?
  process_pending
end