Class: Plutonium::Interaction::Outcome::Success
- Inherits:
-
Plutonium::Interaction::Outcome
- Object
- Plutonium::Interaction::Outcome
- Plutonium::Interaction::Outcome::Success
- Defined in:
- lib/plutonium/interaction/outcome.rb
Overview
Represents a successful outcome of an interaction.
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
The value wrapped by this successful outcome.
Instance Method Summary collapse
-
#and_then {|Object| ... } ⇒ Outcome
Chains another operation to be executed with the value of this outcome.
-
#initialize(value) ⇒ Success
constructor
A new instance of Success.
-
#to_response ⇒ Plutonium::Interaction::Response::Base
Converts this successful outcome to a response object.
- #with_file_response ⇒ Object
- #with_redirect_response ⇒ Object
- #with_render_response ⇒ Object
-
#with_response(response) ⇒ self
Sets the response for this successful outcome.
Methods inherited from Plutonium::Interaction::Outcome
#failure?, #messages, #success?, #with_message
Constructor Details
#initialize(value) ⇒ Success
Returns a new instance of Success.
69 70 71 |
# File 'lib/plutonium/interaction/outcome.rb', line 69 def initialize(value) @value = value end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns The value wrapped by this successful outcome.
66 67 68 |
# File 'lib/plutonium/interaction/outcome.rb', line 66 def value @value end |
Instance Method Details
#and_then {|Object| ... } ⇒ Outcome
Chains another operation to be executed with the value of this outcome.
77 78 79 |
# File 'lib/plutonium/interaction/outcome.rb', line 77 def and_then yield value end |
#to_response ⇒ Plutonium::Interaction::Response::Base
Converts this successful outcome to a response object.
106 107 108 109 110 111 |
# File 'lib/plutonium/interaction/outcome.rb', line 106 def to_response @to_response ||= begin @response ||= Response::Null.new(value) @response.with_flash() end end |
#with_file_response ⇒ Object
99 100 101 |
# File 'lib/plutonium/interaction/outcome.rb', line 99 def with_file_response(*, **) with_response(Response::File.new(*, **)) end |
#with_redirect_response ⇒ Object
91 92 93 |
# File 'lib/plutonium/interaction/outcome.rb', line 91 def with_redirect_response(*, **) with_response(Response::Redirect.new(*, **)) end |
#with_render_response ⇒ Object
95 96 97 |
# File 'lib/plutonium/interaction/outcome.rb', line 95 def with_render_response(*, **) with_response(Response::Render.new(*, **)) end |
#with_response(response) ⇒ self
Sets the response for this successful outcome.
85 86 87 88 89 |
# File 'lib/plutonium/interaction/outcome.rb', line 85 def with_response(response) @to_response = nil @response = response self end |