Method: Mongoid::Attributes#remove_attribute
- Defined in:
- lib/mongoid/attributes.rb
#remove_attribute(name) ⇒ Object
Remove a value from the Document
attributes. If the value does not exist it will fail gracefully.
141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/mongoid/attributes.rb', line 141 def remove_attribute(name) access = name.to_s unless attribute_writable?(name) raise Errors::ReadonlyAttribute.new(name, :nil) end _assigning do attribute_will_change!(access) delayed_atomic_unsets[atomic_attribute_name(access)] = [] unless new_record? attributes.delete(access) end end |