Sha256: 3ad0ac1c4c1b85614fe1c598117d616d87ef49ae286f39af8a7566ced165e999

Contents?: true

Size: 804 Bytes

Versions: 14

Compression:

Stored size: 804 Bytes

Contents

# frozen_string_literal: true

module ActiveRecord::Acts::List::CallbackDefiner #:nodoc:
  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_commit :clear_scope_changed

      if add_new_at.present?
        before_create "add_to_list_#{add_new_at}".to_sym, unless: :act_as_list_no_update?
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
acts_as_list-1.0.4 lib/acts_as_list/active_record/acts/callback_definer.rb
acts_as_list-1.0.3 lib/acts_as_list/active_record/acts/callback_definer.rb
acts_as_list-1.0.2 lib/acts_as_list/active_record/acts/callback_definer.rb
acts_as_list-1.0.1 lib/acts_as_list/active_record/acts/callback_definer.rb
acts_as_list-1.0.0 lib/acts_as_list/active_record/acts/callback_definer.rb
acts_as_list-0.9.19 lib/acts_as_list/active_record/acts/callback_definer.rb
acts_as_list-0.9.18 lib/acts_as_list/active_record/acts/callback_definer.rb
acts_as_list-0.9.17 lib/acts_as_list/active_record/acts/callback_definer.rb
acts_as_list-0.9.16 lib/acts_as_list/active_record/acts/callback_definer.rb
acts_as_list-0.9.15 lib/acts_as_list/active_record/acts/callback_definer.rb
acts_as_list-0.9.14 lib/acts_as_list/active_record/acts/callback_definer.rb
acts_as_list-0.9.13 lib/acts_as_list/active_record/acts/callback_definer.rb
acts_as_list-0.9.12 lib/acts_as_list/active_record/acts/callback_definer.rb
acts_as_list-0.9.11 lib/acts_as_list/active_record/acts/callback_definer.rb