class Laminar::Context

The environment and state of a particle (or flow) invocation. The context provides data required for a particle to do its job. A particle can modify the context during execution to return results, errors, etc.

Public Class Methods

build(context = {}) click to toggle source
# File lib/laminar/context.rb, line 8
def self.build(context = {})
  case context
  when self
    context
  else
    new.merge!(context || {})
  end
end
new() click to toggle source
# File lib/laminar/context.rb, line 17
def initialize
  @halted = false
  @failed = false
end

Public Instance Methods

fail!(context = {}) click to toggle source
# File lib/laminar/context.rb, line 44
def fail!(context = {})
  @failed = true
  halt!(context)
end
failed?() click to toggle source
# File lib/laminar/context.rb, line 26
def failed?
  @failed
end
halt(context = {}) click to toggle source
# File lib/laminar/context.rb, line 34
def halt(context = {})
  @halted = true
  merge!(context)
end
halt!(context = {}) click to toggle source
# File lib/laminar/context.rb, line 39
def halt!(context = {})
  halt(context)
  raise ParticleStopped, self
end
halted?() click to toggle source
# File lib/laminar/context.rb, line 30
def halted?
  @halted
end
success?() click to toggle source
# File lib/laminar/context.rb, line 22
def success?
  !failed?
end