Class: SpecForge::Step::Call

Inherits:
Object
  • Object
show all
Defined in:
lib/spec_forge/step/call.rb

Overview

Represents a callback invocation within a step

Holds the callback name and any arguments to pass when the callback is executed during step processing.

Class Method Summary collapse

Class Method Details

.wrap_hooks(hooks) ⇒ Hash{Symbol => Array<Call>}

Transforms raw hook data into Call objects

Parameters:

  • hooks (Hash, nil)

    Raw hooks hash with callback definitions

Returns:

  • (Hash{Symbol => Array<Call>})

    Transformed hooks with Call objects



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/spec_forge/step/call.rb', line 19

def self.wrap_hooks(hooks)
  hooks = hooks&.compact_blank
  return {} if hooks.blank?

  hooks.transform_values do |call|
    calls =
      if call.is_a?(Set)
        call.to_a
      else
        Array.wrap(call)
      end

    calls.map { |c| Call.new(callback_name: c[:name], arguments: c[:arguments]) }
  end
end