Class: WorkflowTemplate::State::Final
- Inherits:
-
Object
- Object
- WorkflowTemplate::State::Final
show all
- Includes:
- Abstract
- Defined in:
- lib/workflow_template/state/final.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Abstract
#bare_state, #error, #error?
Constructor Details
#initialize(wrapped_state, meta, state_class) ⇒ Final
Returns a new instance of Final.
16
17
18
19
|
# File 'lib/workflow_template/state/final.rb', line 16
def initialize(wrapped_state, meta, state_class)
@state_class = state_class
super(wrapped_state, meta)
end
|
Instance Attribute Details
Returns the value of attribute meta.
14
15
16
|
# File 'lib/workflow_template/state/final.rb', line 14
def meta
@meta
end
|
#state_class ⇒ Object
Returns the value of attribute state_class.
14
15
16
|
# File 'lib/workflow_template/state/final.rb', line 14
def state_class
@state_class
end
|
#wrapped_state ⇒ Object
Returns the value of attribute wrapped_state.
14
15
16
|
# File 'lib/workflow_template/state/final.rb', line 14
def wrapped_state
@wrapped_state
end
|
Instance Method Details
#fetch(key) ⇒ Object
33
34
35
|
# File 'lib/workflow_template/state/final.rb', line 33
def fetch(key)
unwrap(fetch: key)
end
|
#slice(*keys) ⇒ Object
37
38
39
|
# File 'lib/workflow_template/state/final.rb', line 37
def slice(*keys)
unwrap(slice: keys)
end
|
#status ⇒ Object
21
22
23
|
# File 'lib/workflow_template/state/final.rb', line 21
def status
error? ? :error : :ok
end
|
#to_result(adapter = nil, **opts) ⇒ Object
41
42
43
|
# File 'lib/workflow_template/state/final.rb', line 41
def to_result(adapter = nil, **opts)
error? ? rewrap_error(adapter) : rewrap_success(adapter, **opts)
end
|
#unwrap(slice: nil, fetch: nil) ⇒ Object
25
26
27
28
29
30
31
|
# File 'lib/workflow_template/state/final.rb', line 25
def unwrap(slice: nil, fetch: nil)
raise_error! if error?
return bare_state if slice.nil? && fetch.nil?
normalized_bare_state = Normalizer.instance(slice).normalize(bare_state)
fetch.nil? ? normalized_bare_state.values : normalized_bare_state.fetch(fetch, nil)
end
|