diff --git a/lib/state_machines/audit_trail/transition_auditing.rb b/lib/state_machines/audit_trail/transition_auditing.rb index c4b6108..10e3216 100644 --- a/lib/state_machines/audit_trail/transition_auditing.rb +++ b/lib/state_machines/audit_trail/transition_auditing.rb @@ -1,4 +1,3 @@ -require 'ostruct' # # This module inserts hooks into the state machine. # The transition_class is the class (optionally specified with the :class option) for the model which @@ -7,6 +6,14 @@ # Multiple `SubscriptionStateTransition`s compose the 'audit_trail'. # module StateMachines::AuditTrail::TransitionAuditing + class LogInfo + attr_reader :namespace, :to + + def initialize(namespace:, to:) + @namespace = namespace + @to = to + end + end # Hook for audit_trail inside a a state_machine declaration. # @@ -35,7 +42,7 @@ def audit_trail(options = {}) if state_machine.backend.new_record? object current_state = object.send(state_machine.attribute) if !current_state.nil? - state_machine.backend.log(object, OpenStruct.new(namespace: state_machine.namespace, to: current_state)) + state_machine.backend.log(object, LogInfo.new(namespace: state_machine.namespace, to: current_state)) end end end