Class: SpecForge::Forge::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/spec_forge/forge/context.rb

Overview

Immutable execution context passed to callbacks and hooks

Contains the current state during forge execution including variables, the current blueprint and step, and any error that occurred.

Instance Method Summary collapse

Constructor Details

#initialize(**context) ⇒ Context

Returns a new instance of Context.



12
13
14
15
16
17
18
19
20
# File 'lib/spec_forge/forge/context.rb', line 12

def initialize(**context)
  context[:variables] ||= nil
  context[:forge] ||= nil
  context[:blueprint] ||= nil
  context[:step] ||= nil
  context[:error] ||= nil

  super(context)
end

Instance Method Details

#failure?Boolean

Returns whether the context represents a failed state

Returns:

  • (Boolean)

    True if an error is present



36
37
38
# File 'lib/spec_forge/forge/context.rb', line 36

def failure?
  !success?
end

#success?Boolean

Returns whether the context represents a successful state

Returns:

  • (Boolean)

    True if no error is present



27
28
29
# File 'lib/spec_forge/forge/context.rb', line 27

def success?
  error.nil?
end