Module: Statecraft::Mounting

Defined in:
lib/statecraft/mounting.rb

Overview

The model-side macro. state_machine OrderFlow, ... mounts a compiled machine onto an ActiveRecord model: resolves the log class (convention <base_class>Transition, overridable via log:), runs the mounting-time checks (AlreadyMounted, composite primary keys, connection-class identity), finalizes the machine, verifies helper and scope name conflicts, generates scopes, and defines the reading surface (history, last_transition, in_state?). Everything internal goes through base_class.

Defined Under Namespace

Classes: Builder, Configuration

Instance Method Summary collapse

Instance Method Details

#state_machine(machine_class, log: nil, column: :state, changed_at: false, versioning: false, touch: true, helpers: false, scopes: false) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/statecraft/mounting.rb', line 18

def state_machine(machine_class, log: nil, column: :state, changed_at: false,
                  versioning: false, touch: true, helpers: false, scopes: false)
  Builder.new(
    model: self, machine_class: machine_class, log: log, column: column,
    changed_at: changed_at, versioning: versioning, touch: touch,
    helpers: helpers, scopes: scopes
  ).mount
end