Module: ActiveRecord::Acts::List::CallbackDefiner

Defined in:
lib/acts_as_list/active_record/acts/callback_definer.rb

Overview

:nodoc:

Class Method Summary collapse

Class Method Details

.call(caller_class, add_new_at) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/acts_as_list/active_record/acts/callback_definer.rb', line 4

def self.call(caller_class, add_new_at)
  caller_class.class_eval do
    before_validation :check_top_position, unless: :act_as_list_no_update?

    before_destroy :reload, unless: Proc.new { new_record? || destroyed_via_scope? || act_as_list_no_update? }
    after_destroy :decrement_positions_on_lower_items, unless: Proc.new { destroyed_via_scope? || act_as_list_no_update? }

    before_update :check_scope, unless: :act_as_list_no_update?
    after_update :update_positions, unless: :act_as_list_no_update?

    after_save :clear_scope_changed

    before_create :avoid_collision, unless: :act_as_list_no_update?
  end
end