Class: Salestation::App::Request
- Inherits:
-
Object
- Object
- Salestation::App::Request
- Defined in:
- lib/salestation/app/request.rb
Instance Attribute Summary collapse
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#span ⇒ Object
readonly
Returns the value of attribute span.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize_hook(hook, payload) ⇒ Object
Initializes an asynchronous application hook.
- #replace_input(new_input) ⇒ Object
- #to_failure(input) ⇒ Object
- #to_success ⇒ Object
- #with_input(input_additions) ⇒ Object
Instance Attribute Details
#env ⇒ Object (readonly)
Returns the value of attribute env.
13 14 15 |
# File 'lib/salestation/app/request.rb', line 13 def env @env end |
#input ⇒ Object (readonly)
Returns the value of attribute input.
13 14 15 |
# File 'lib/salestation/app/request.rb', line 13 def input @input end |
#span ⇒ Object (readonly)
Returns the value of attribute span.
13 14 15 |
# File 'lib/salestation/app/request.rb', line 13 def span @span end |
Class Method Details
.create(env:, input:, initialize_hook: nil, span: nil) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/salestation/app/request.rb', line 4 def self.create(env:, input:, initialize_hook: nil, span: nil) new( env: env, input: input, initialize_hook: initialize_hook, span: span ).to_success end |
Instance Method Details
#initialize_hook(hook, payload) ⇒ Object
Initializes an asynchronous application hook
Set a listener on App instance to receive a notification when the asynchronous process completes.
40 41 42 |
# File 'lib/salestation/app/request.rb', line 40 def initialize_hook(hook, payload) @initialize_hook.call(hook, payload) end |
#replace_input(new_input) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/salestation/app/request.rb', line 19 def replace_input(new_input) self.class.new( env: env, input: new_input, initialize_hook: @initialize_hook, span: span ).to_success end |
#to_failure(input) ⇒ Object
32 33 34 |
# File 'lib/salestation/app/request.rb', line 32 def to_failure(input) Deterministic::Result::Failure(input) end |
#to_success ⇒ Object
28 29 30 |
# File 'lib/salestation/app/request.rb', line 28 def to_success Deterministic::Result::Success(self) end |
#with_input(input_additions) ⇒ Object
15 16 17 |
# File 'lib/salestation/app/request.rb', line 15 def with_input(input_additions) replace_input(input.merge(input_additions)) end |