Class: Callbacks::UniqueKeyBeforeUpdate
- Inherits:
-
Object
- Object
- Callbacks::UniqueKeyBeforeUpdate
- Includes:
- Restrictor
- Defined in:
- app/models/callbacks/unique_key_before_update.rb
Instance Method Summary collapse
Instance Method Details
#call ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'app/models/callbacks/unique_key_before_update.rb', line 19 def call m.with_buffered_position(@position) do update_list m.other_locales(@position_was).each do |unique_key| unique_key.with_buffered_position(@position) do update_list(unique_key.locale) end end end end |
#init ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/models/callbacks/unique_key_before_update.rb', line 5 def init # keep position and position_was, because buffered_position rewrites them @position, @position_was = m.position, m.position_was if @position_was < @position # move list range downward @range = (@position_was + 1)..@position @reverse = false else # move list range upward @range = @position..(@position_was - 1) @reverse = true end end |