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_OPTIONS =
{
  messages_supports_array: :undefined,
  column_mappings: {
    at: :at,
    event: :event,
    to_state: :to_state,
    from_state: :from_state,
    reason: :reason,
    messages: :messages,
    actor_id: :actor_id,
  }.freeze,
}.freeze

Class Method Summary collapse

Class Method Details

.configure(model, opts = DEFAULT_OPTIONS) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/sequel/plugins/state_machine_audit_log.rb', line 21

def self.configure(model, opts=DEFAULT_OPTIONS)
  opts = DEFAULT_OPTIONS.merge(opts)
  model.state_machine_column_mappings = opts[:column_mappings]
  msgarray = opts[:messages_supports_array] || true
  if msgarray == :undefined
    msgcol = model.state_machine_column_mappings[:messages]
    dbt = model.db_schema[msgcol][:db_type]
    msgarray = dbt.include?("json") || dbt.include?("[]")
  end
  model.state_machine_messages_supports_array = msgarray
end