ActiveRecord::Base.class_eval do
  # SYNC CALLBACKS
  define_callbacks :sync

  def self.before_sync(method, options = {})
    set_callback :sync, :before, method, options
  end

  def self.after_sync(method, options = {})
    set_callback :sync, :after, method, options
  end

  # SYNC STATUS
  def self.inherited(subclass)
    super

    subclass.class_eval do
      has_one :stagehand_unsynced_indicator,
        lambda { where(:stagehand_commit_entries => {:table_name => subclass.table_name}).readonly },
        :class_name => Stagehand::Staging::CommitEntry,
        :foreign_key => :record_id

      def synced?
        stagehand_unsynced_indicator.blank?
      end
    end
  end
end

ActiveRecord::Base.class_eval do
  # SYNC CALLBACKS
  define_model_callbacks :sync

  # SYNC STATUS
  def self.inherited(subclass)
    super

    subclass.class_eval do
      has_one :stagehand_unsynced_indicator,
        lambda { where(:stagehand_commit_entries => {:table_name => subclass.table_name}).readonly },
        :class_name => Stagehand::Staging::CommitEntry,
        :foreign_key => :record_id

      def synced?
        stagehand_unsynced_indicator.blank?
      end
    end
  end
end

Use model callbacks instead of generic callbacks
Use model callbacks instead of generic callbacks
