Class: StateMachine::AuditTrail::Backend::Mongoid
- Inherits:
-
StateMachine::AuditTrail::Backend
- Object
- StateMachine::AuditTrail::Backend
- StateMachine::AuditTrail::Backend::Mongoid
- Defined in:
- lib/state_machine/audit_trail/backend/mongoid.rb
Overview
This is the class that does the actual logging. We need one of these per ORM
Instance Method Summary collapse
-
#log(object, event, from, to, timestamp = Time.now) ⇒ Object
Public writes the log to the database.
Instance Method Details
#log(object, event, from, to, timestamp = Time.now) ⇒ Object
Public writes the log to the database
object: the object being watched by the state_machine observer event: the event being observed by the state machine from: the state of the object prior to the event to: the state of the object after the event
12 13 14 15 16 |
# File 'lib/state_machine/audit_trail/backend/mongoid.rb', line 12 def log(object, event, from, to, = Time.now) tc = transition_class foreign_key_field = tc.relations.keys.first transition_class.create(foreign_key_field => object, :event => event, :from => from, :to => to, :create_at => ) end |