Method: Mongoid::Attributes::Dynamic#process_attribute

Defined in:
lib/mongoid/attributes/dynamic.rb

#process_attribute(name, value) ⇒ Object

If the attribute is dynamic, add a field for it with a type of object and set the value.

Examples:

Process the attribute.

document.process_attribute(name, value)

Parameters:

  • name (Symbol)

    The name of the field.

  • value (Object)

    The value of the field.



89
90
91
92
93
94
95
96
# File 'lib/mongoid/attributes/dynamic.rb', line 89

def process_attribute(name, value)
  responds = respond_to?("#{name}=")
  if !responds
    write_attribute(name, value)
  else
    send("#{name}=", value)
  end
end