Class: Grumlin::Steppable

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/grumlin/steppable.rb

Direct Known Subclasses

Step, TraversalStart

Constant Summary collapse

START_STEPS =
Grumlin.definitions.dig(:steps, :start).map(&:to_sym).freeze
REGULAR_STEPS =
Grumlin.definitions.dig(:steps, :regular).map(&:to_sym).freeze
CONFIGURATION_STEPS =
Grumlin.definitions.dig(:steps, :configuration).map(&:to_sym).freeze
ALL_STEPS =
START_STEPS + CONFIGURATION_STEPS + REGULAR_STEPS

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pool: nil, session_id: nil, middlewares: Grumlin.default_middlewares) ⇒ Steppable

Returns a new instance of Steppable.



14
15
16
17
18
19
20
21
22
# File 'lib/grumlin/steppable.rb', line 14

def initialize(pool: nil, session_id: nil, middlewares: Grumlin.default_middlewares)
  @pool = pool
  @session_id = session_id
  @middlewares = middlewares

  return if respond_to?(:shortcuts)

  raise "steppable must not be initialized directly, use Grumlin::Shortcuts::Storage#g or #__ instead"
end

Instance Attribute Details

#poolObject (readonly)

Returns the value of attribute pool.



6
7
8
# File 'lib/grumlin/steppable.rb', line 6

def pool
  @pool
end

#session_idObject (readonly)

Returns the value of attribute session_id.



6
7
8
# File 'lib/grumlin/steppable.rb', line 6

def session_id
  @session_id
end

Instance Method Details

#step(name, *args, **params) ⇒ Object



31
32
33
34
# File 'lib/grumlin/steppable.rb', line 31

def step(name, *args, **params)
  shortcuts.step_class.new(name, args:, params:, previous_step: self,
                                 session_id: @session_id, pool: @pool, middlewares: @middlewares)
end