Class: Mongoid::Orderable::Handlers::Document

Inherits:
Base
  • Object
show all
Defined in:
lib/mongoid/orderable/handlers/document.rb

Direct Known Subclasses

DocumentEmbedded, DocumentTransactional

Instance Attribute Summary

Attributes inherited from Base

#doc

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Mongoid::Orderable::Handlers::Base

Instance Method Details

#after_createObject



12
13
14
# File 'lib/mongoid/orderable/handlers/document.rb', line 12

def after_create
  reset
end

#after_destroyObject



25
26
27
28
# File 'lib/mongoid/orderable/handlers/document.rb', line 25

def after_destroy
  remove_all_positions
  reset
end

#after_updateObject



21
22
23
# File 'lib/mongoid/orderable/handlers/document.rb', line 21

def after_update
  reset
end

#before_createObject



7
8
9
10
# File 'lib/mongoid/orderable/handlers/document.rb', line 7

def before_create
  set_new_record_positions
  apply_all_positions
end

#before_updateObject



16
17
18
19
# File 'lib/mongoid/orderable/handlers/document.rb', line 16

def before_update
  return unless any_field_changed?
  apply_all_positions
end