Class: Dry::Mutations::Extensions::Either::EitherCalculator
- Inherits:
-
Object
- Object
- Dry::Mutations::Extensions::Either::EitherCalculator
- Includes:
- Dry::Monads::Either::Mixin
- Defined in:
- lib/dry/mutations/extensions/outcome.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#either ⇒ Object
readonly
Returns the value of attribute either.
-
#outcome ⇒ Object
readonly
Returns the value of attribute outcome.
Instance Method Summary collapse
-
#initialize(outcome) ⇒ EitherCalculator
constructor
rubocop:disable Style/VariableNumber.
Constructor Details
#initialize(outcome) ⇒ EitherCalculator
rubocop:disable Style/VariableNumber
13 14 15 16 17 18 |
# File 'lib/dry/mutations/extensions/outcome.rb', line 13 def initialize(outcome) @∨ = outcome.class.instance_variable_get(:@∨) @either = Right(@outcome = outcome).bind do |value| value.public_send(@∨[:success]) ? Right(value.public_send(@∨[:right])) : Left(value.public_send(@∨[:left])) end end |
Instance Attribute Details
#either ⇒ Object (readonly)
Returns the value of attribute either.
10 11 12 |
# File 'lib/dry/mutations/extensions/outcome.rb', line 10 def either @either end |
#outcome ⇒ Object (readonly)
Returns the value of attribute outcome.
10 11 12 |
# File 'lib/dry/mutations/extensions/outcome.rb', line 10 def outcome @outcome end |