Module: Sequel::Plugins::StateMachineAuditLog
- Defined in:
- lib/sequel/plugins/state_machine_audit_log.rb
Defined Under Namespace
Modules: ClassMethods, DatasetMethods, InstanceMethods
Constant Summary collapse
- DEFAULT_COLUMN_MAPPINGS =
{ at: :at, event: :event, to_state: :to_state, from_state: :from_state, reason: :reason, messages: :messages, actor_id: :actor_id, actor: :actor, machine_name: :machine_name, }.freeze
- DEFAULT_OPTIONS =
{ messages_supports_array: :undefined, column_mappings: DEFAULT_COLUMN_MAPPINGS, }.freeze
Class Method Summary collapse
Class Method Details
.configure(model, opts = DEFAULT_OPTIONS) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/sequel/plugins/state_machine_audit_log.rb', line 24 def self.configure(model, opts=DEFAULT_OPTIONS) opts = DEFAULT_OPTIONS.merge(opts) colmap = opts[:column_mappings] actor_key_mismatch = (colmap.key?(:actor) && !colmap.key?(:actor_id)) || (!colmap.key?(:actor) && colmap.key?(:actor_id)) if actor_key_mismatch msg = "Remapping columns :actor and :actor_id must both be supplied" raise Sequel::Plugins::StateMachine::InvalidConfiguration, msg end colmap = DEFAULT_COLUMN_MAPPINGS.merge(colmap) model.state_machine_column_mappings = colmap msgarray = opts[:messages_supports_array] || true if msgarray == :undefined msgcol = model.state_machine_column_mappings[:messages] if model.db_schema && model.db_schema[msgcol] dbt = model.db_schema[msgcol][:db_type] msgarray = dbt.include?("json") || dbt.include?("[]") end end model. = msgarray end |