Module: Mongoid::Persistable::Poppable
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
ActiveSupport::Concern
|
|
Defined in: | lib/mongoid/persistable/poppable.rb |
Overview
Defines behavior for $pop operations.
Instance Method Summary
-
#pop(pops) ⇒ Document
Pop or shift items from arrays using the $pop operator.
Instance Method Details
#pop(pops) ⇒ Document
Pop or shift items from arrays using the $pop operator.
# File 'lib/mongoid/persistable/poppable.rb', line 25
def pop(pops) prepare_atomic_operation do |ops| process_atomic_operations(pops) do |field, value| values = send(field) value > 0 ? values.pop : values.shift ops[atomic_attribute_name(field)] = value end { "$pop" => ops } end end