module Logux::Model

Public Class Methods

included(base) click to toggle source
# File lib/logux/model.rb, line 12
def self.included(base)
  base.extend(DSL)

  base.before_update :touch_logux_order_for_changes,
                     unless: -> { changes.key?('logux_fields_updated_at') }
end

Public Instance Methods

logux() click to toggle source
# File lib/logux/model.rb, line 19
def logux
  Proxy.new(self)
end

Private Instance Methods

touch_logux_order_for_changes() click to toggle source
# File lib/logux/model.rb, line 25
def touch_logux_order_for_changes
  attributes = changed.each_with_object({}) do |attr, res|
    res[attr] = send(attr)
  end

  updater = Updater.new(model: self, attributes: attributes)
  self.logux_fields_updated_at = updater.updated_attributes

  ActiveSupport::Notifications.instrument(
    Logux::Model::UpdatesDeprecator::EVENT,
    model: self
  )
end