Class Statemachine::StatemachineBuilder
In: lib/statemachine/builder.rb
Parent: Builder

Created by Statemachine.build as the root context for building the statemachine.

Methods

context   new   stub_context  

Included Modules

SuperstateBuilding

Public Class methods

[Source]

     # File lib/statemachine/builder.rb, line 247
247:     def initialize(statemachine = Statemachine.new)
248:       super statemachine
249:       @subject = @statemachine.root
250:     end

Public Instance methods

Used the set the context of the statemahine within the builder.

  sm = Statemachine.build do
    ...
    context MyContext.new
  end

Statemachine.context may also be used.

[Source]

     # File lib/statemachine/builder.rb, line 260
260:     def context(a_context)
261:       @statemachine.context = a_context
262:       a_context.statemachine = @statemachine if a_context.respond_to?(:statemachine=)
263:     end

Stubs the context. This makes statemachine immediately useable, even if functionless. The stub will print all the actions called so it‘s nice for trial runs.

  sm = Statemachine.build do
    ...
    stub_context :verbose => true
  end

Statemachine.context may also be used.

[Source]

     # File lib/statemachine/builder.rb, line 274
274:     def stub_context(options={})
275:       require 'statemachine/stub_context'
276:       context StubContext.new(options)
277:     end

[Validate]