Class: Dry::Mutations::Extensions::Either::EitherCalculator

Inherits:
Object
  • Object
show all
Includes:
Dry::Monads::Either::Mixin
Defined in:
lib/dry/mutations/extensions/outcome.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#eitherObject (readonly)

Returns the value of attribute either.



10
11
12
# File 'lib/dry/mutations/extensions/outcome.rb', line 10

def either
  @either
end

#outcomeObject (readonly)

Returns the value of attribute outcome.



10
11
12
# File 'lib/dry/mutations/extensions/outcome.rb', line 10

def outcome
  @outcome
end