Class: NucleusCore::Operation::Context

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/nucleus_core/operation.rb

Defined Under Namespace

Classes: Error

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Context

Returns a new instance of Context.



18
19
20
21
22
# File 'lib/nucleus_core/operation.rb', line 18

def initialize(attrs={})
  @failure = false

  super(attrs)
end

Instance Attribute Details

#failureObject (readonly)

Returns the value of attribute failure.



16
17
18
# File 'lib/nucleus_core/operation.rb', line 16

def failure
  @failure
end

Instance Method Details

#fail!(message, attrs = {}) ⇒ Object

Raises:



28
29
30
31
32
33
34
35
# File 'lib/nucleus_core/operation.rb', line 28

def fail!(message, attrs={})
  @failure = true

  self.message = message
  self.exception = attrs.delete(:exception)

  raise Context::Error, message
end

#success?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/nucleus_core/operation.rb', line 24

def success?
  !@failure
end