Module: LogBook::Plugin::ClassMethods

Defined in:
lib/log_book/plugin.rb

Instance Method Summary collapse

Instance Method Details

#log_book(opts = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/log_book/plugin.rb', line 8

def log_book(opts = {})
  after_create :log_book_event_on_create
  after_update :log_book_event_on_update
  before_destroy :log_book_event_on_destroy

  has_many :log_book_events, :class_name => "LogBook::Event", :as => :historizable, :dependent => (opts[:dependent] || :nullify)

  attr_accessor :log_book_historian
  attr_accessor :log_book_mute
  cattr_accessor :log_book_options

  self.log_book_options = opts
  self.log_book_options[:ignore] ||= []
  self.log_book_options[:ignore] << :updated_at # ignoring noisy field
end