Module: Laminar::Particle::InstanceMethods

Defined in:
lib/laminar/particle.rb

Overview

Laminar::Particle instance methods.

Instance Method Summary collapse

Instance Method Details

#callObject



57
# File 'lib/laminar/particle.rb', line 57

def call; end

#initialize(context = {}) ⇒ Object



31
32
33
# File 'lib/laminar/particle.rb', line 31

def initialize(context = {})
  @context = Context.build(context)
end

#invokeObject



35
36
37
38
39
# File 'lib/laminar/particle.rb', line 35

def invoke
  invoke!
rescue ParticleStopped
  context
end

#invoke!Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/laminar/particle.rb', line 41

def invoke!
  begin
    run_before_callbacks
    return context if context.halted?

    param_list = context_slice
    param_list.empty? ? call : call(**context_slice)
    run_after_callbacks unless context.halted?
  rescue ParticleStopped
    run_final_callbacks
    raise
  end
  run_final_callbacks
  context
end