lib/moribus/tracked_behavior.rb
# The main callback for tracked behavior (see module description). Note
# that since AR objects are saved in transaction via AR::Transactions
# module, no self.class.transaction{} block is used here. If an exception
# has been raised during execution, the record returns to its persisted
# state with its old id.
The main callback for tracked behavior . Note
that since AR objects are saved in transaction via AR::Transactions
module, no self.class.transaction{} block is used here. If an exception
has been raised during execution, the record returns to its persisted
state with its old id.
The main callback for tracked behavior . Note that since AR objects are saved in transaction via AR :: Transactions module no self . class . transaction {} block is used here . If an exception has been raised during execution the record returns to its persisted state with its old id .
def tracked_save_callback
      if content_changed? && persisted?
        to_new_record!
        set_parent
        begin
          if update_current
            set_lock
            yield
          end
        ensure
          to_persistent! if new_record?
        end
      else
        set_lock if new_record?
        yield
      end
    end
def tracked_save_callback if content_changed? && persisted? to_new_record! set_parent begin if update_current set_lock yield end ensure to_persistent! if new_record? end else set_lock if new_record? yield end end
The main callback for tracked behavior (see module description).
The main callback for tracked behavior ( see module description ) .
# SQL UPDATE statement is executed in first place to prevent # crashing on uniqueness constraints with 'is_current' condition.