Class: Activities::Logger

Inherits:
ActiveRecord::Observer
  • Object
show all
Defined in:
app/observers/activities/logger.rb

Direct Known Subclasses

ArticleObserver, CommentObserver

Defined Under Namespace

Classes: Configurator

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.logs_activity(options = {}) {|Configurator.new(self)| ... } ⇒ Object

Yields:



8
9
10
11
# File 'app/observers/activities/logger.rb', line 8

def logs_activity(options = {})
  self.activity_attributes += options[:attributes] if options[:attributes]
  yield Configurator.new(self) if block_given?
end

Instance Method Details

#after_destroy(record) ⇒ Object



33
34
35
36
# File 'app/observers/activities/logger.rb', line 33

def after_destroy(record)
  prepare_activity_logging(record)
  log_activity(record)
end

#after_save(record) ⇒ Object



29
30
31
# File 'app/observers/activities/logger.rb', line 29

def after_save(record)
  log_activity(record)
end

#before_save(record) ⇒ Object



25
26
27
# File 'app/observers/activities/logger.rb', line 25

def before_save(record)
  prepare_activity_logging(record)
end