Module: Mongoid::Persistable::Unsettable
- Extended by:
- ActiveSupport::Concern
- Included in:
- Mongoid::Persistable
- Defined in:
- lib/mongoid/persistable/unsettable.rb
Overview
Defines behaviour for $unset operations.
Instance Method Summary collapse
-
#unset(*fields) ⇒ true
Perform an $unset operation on the provided fields and in the values in the document in memory.
Instance Method Details
#unset(*fields) ⇒ true
Perform an $unset operation on the provided fields and in the values in the document in memory.
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/mongoid/persistable/unsettable.rb', line 23 def unset(*fields) prepare_atomic_operation do |ops| fields.flatten.each do |field| normalized = database_field_name(field) attributes.delete(normalized) ops[atomic_attribute_name(normalized)] = true end { "$unset" => ops } end end |