Class: Plutonium::Interaction::Outcome::Failure

Inherits:
Plutonium::Interaction::Outcome show all
Defined in:
lib/plutonium/interaction/outcome.rb

Overview

Represents a failed outcome of an interaction.

Instance Method Summary collapse

Methods inherited from Plutonium::Interaction::Outcome

#failure?, #messages, #success?

Instance Method Details

#and_thenself

Returns self without executing the given block, propagating the failure.

Returns:

  • (self)


128
129
130
# File 'lib/plutonium/interaction/outcome.rb', line 128

def and_then
  self
end

#to_responsePlutonium::Interaction::Response::Null

Converts this failure outcome to a response object.

Returns:



142
143
144
145
146
147
# File 'lib/plutonium/interaction/outcome.rb', line 142

def to_response
  @to_response ||= begin
    @response ||= Response::Failure.new
    @response.with_flash(messages)
  end
end

#with_message(msg, type = :alert) ⇒ self

Adds a message to the outcome.

Parameters:

  • msg (String)

    The message to add.

  • type (Symbol) (defaults to: :alert)

    The type of the message (e.g., :notice, :alert).

Returns:

  • (self)


121
122
123
# File 'lib/plutonium/interaction/outcome.rb', line 121

def with_message(msg, type = :alert)
  super
end

#with_response(response) ⇒ self

Returns self without setting a response.

Returns:

  • (self)


135
136
137
# File 'lib/plutonium/interaction/outcome.rb', line 135

def with_response(response)
  self
end