Module: ActsAsLoggable

Extended by:
ActiveSupport::Concern
Defined in:
app/models/concerns/acts_as_loggable.rb

Defined Under Namespace

Modules: Base, ClassMethods

Instance Method Summary collapse

Instance Method Details

#log_changes?Boolean

Disable logging of changes for this resource

Returns:

  • (Boolean)


58
59
60
# File 'app/models/concerns/acts_as_loggable.rb', line 58

def log_changes?
  true # Can be overridden to suppress logging
end

#log_changes_datatableObject



84
85
86
87
# File 'app/models/concerns/acts_as_loggable.rb', line 84

def log_changes_datatable
  # We use the changes_to_type and changes_to_id so that the bootstrap3 datatable is still aware of the resources
  EffectiveLogChangesDatatable.new(changes_to: self, changes_to_type: self.class.name, changes_to_id: id) if persisted?
end

#log_changes_formatted_attribute(attribute) ⇒ Object

Format the title of this attribute. Return nil to use the default attribute.titleize



71
72
73
# File 'app/models/concerns/acts_as_loggable.rb', line 71

def log_changes_formatted_attribute(attribute)
  'Roles' if attribute == :roles_mask && defined?(EffectiveRoles) && respond_to?(:roles)
end

#log_changes_formatted_value(attribute, value) ⇒ Object

Format the value of this attribute. Return nil to use the default to_s



76
77
78
# File 'app/models/concerns/acts_as_loggable.rb', line 76

def log_changes_formatted_value(attribute, value)
  EffectiveRoles.roles_for(value) if attribute == :roles_mask && defined?(EffectiveRoles) && respond_to?(:roles)
end

#log_changes_to_sObject



62
63
64
65
66
67
68
# File 'app/models/concerns/acts_as_loggable.rb', line 62

def log_changes_to_s
  if self.class.name == 'ActiveStorage::Attachment'
    "#{name} - #{filename}"
  else
    to_s
  end
end

#logs_datatableObject



80
81
82
# File 'app/models/concerns/acts_as_loggable.rb', line 80

def logs_datatable
  EffectiveLogsDatatable.new(for: self) if persisted?
end