Class: MassiveRecord::ORM::Observer
- Inherits:
-
ActiveModel::Observer
- Object
- ActiveModel::Observer
- MassiveRecord::ORM::Observer
- Defined in:
- lib/massive_record/orm/observer.rb
Overview
MassiveRecord Observer. Greatly influenced by ActiveRecord’s way of doing callbacks, thus should feel familiar to most people.
NOTE that if you are using rails you should add observers to into
your application.rb configuration file like this:
config.massive_record.observers = :person_observer, :audit_observer
This will ensure that observers are loaded correctly. If you are not
using rails you can do: MassiveRecord::ORM::Base.instantiate_observers
after your application has been initialized.
Example of usage:
class Person < MassiveRecord::ORM::Table
column_family :info do
field :name
end
end
class PersonObserver < MassiveRecord::ORM::Observer
def after_save(saved_person_record)
# do something here after people are being saved
end
end
class AuditObserver < MassiveRecord::ORM::Observer
observe :person, :and, :other, :classes
def after_save(saved_person_record)
# do something here after people are being saved
end
end