Exception: Statefully::Errors::StateMissing

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/statefully/errors.rb

Overview

StateMissing represents an error being thrown when a member of State is being accessed using an unsafe accessor (eg. #member!). It is technically a NoMethodError, but it is introduced to allow users to differentiate between failing state accessors and other code that may fail in a similar way.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(field) ⇒ StateMissing

Error constructor for Statefully::Errors::StateMissing

Examples:

Statefully::Errors::StateMissing.new(:bacon)
=> #<Statefully::Errors::StateMissing: field 'bacon' missing from state>

Parameters:

  • field (Symbol)

    name of the missing field.



26
27
28
29
# File 'lib/statefully/errors.rb', line 26

def initialize(field)
  @field = field
  super("field '#{field}' missing from state")
end

Instance Attribute Details

#fieldSymbol (readonly)

Stores the name of the missing State field

Examples:

Statefully::Errors::StateMissing.new(:bacon).field
=> :bacon

Returns:

  • (Symbol)

    the name of the field.



17
18
19
# File 'lib/statefully/errors.rb', line 17

def field
  @field
end