Module: Parse::Core::EnhancedChangeTracking

Included in:
Object
Defined in:
lib/parse/model/core/enhanced_change_tracking.rb

Overview

Enhanced change tracking for Parse::Object that provides additional _was_changed? and enhanced _was methods for after_save hooks.

This module adds _was_changed? methods that work correctly in after_save contexts by using previous_changes, while keeping normal _changed? methods intact.

Key benefits:

  • _was_changed? methods work correctly in after_save hooks

  • _was methods return actual previous values (not current values) in after_save

  • Normal _changed? methods remain unchanged (standard ActiveModel behavior)

  • Automatically detects context using presence of previous_changes

Examples:

class Product < Parse::Object
  property :name, :string
  property :price, :float

  after_save :send_price_alert

  def send_price_alert
    if price_was_changed? && price_was < price
      AlertService.send("Price increased from $#{price_was} to $#{price}")
    end
  end
end

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



32
33
34
# File 'lib/parse/model/core/enhanced_change_tracking.rb', line 32

def self.included(base)
  base.extend(ClassMethods)
end