Class: Dry::Monads::Validated::Valid Private

Inherits:
Validated
  • Object
show all
Defined in:
lib/dry/monads/validated.rb,
lib/dry/monads/maybe.rb,
lib/dry/monads/result.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Valid result

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Valid

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Valid.



57
58
59
60
61
# File 'lib/dry/monads/validated.rb', line 57

def initialize(value)
  super()

  @value = value
end

Instance Method Details

#===(other) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • other (Object)

Returns:

  • (Boolean)


125
126
127
# File 'lib/dry/monads/validated.rb', line 125

def ===(other)
  other.instance_of?(self.class) && value! === other.value!
end

#alt_map(_ = nil) ⇒ Validated::Valid

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Ignores values and returns self, see Invalid#alt_map

Returns:



106
# File 'lib/dry/monads/validated.rb', line 106

def alt_map(_ = nil, &) = self

#apply(val) ⇒ Validated::Valid, Validated::Invalid #applyValidated::Valid, Validated::Invalid

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Applies another Valid to the stored function

Overloads:



84
85
86
# File 'lib/dry/monads/validated.rb', line 84

def apply(val = Undefined, &)
  Undefined.default(val, &).fmap(Curry.(value!))
end

#fmap(proc) ⇒ Validated::Valid #fmapValidated::Valid

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Lifts a block/proc over Valid

Overloads:



98
99
100
101
# File 'lib/dry/monads/validated.rb', line 98

def fmap(proc = Undefined, &block)
  f = Undefined.default(proc, block)
  self.class.new(f.(value!))
end

#inspectString Also known as: to_s

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (String)


114
115
116
117
118
119
120
# File 'lib/dry/monads/validated.rb', line 114

def inspect
  if Unit.equal?(@value)
    "Valid()"
  else
    "Valid(#{@value.inspect})"
  end
end

#or(_ = nil) ⇒ Validated::Valid

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Ignores arguments, returns self

Returns:



111
# File 'lib/dry/monads/validated.rb', line 111

def or(_ = nil, &) = self

#to_maybeMaybe::Some

Converts to Maybe::Some

Returns:



404
# File 'lib/dry/monads/maybe.rb', line 404

def to_maybe = Maybe.pure(value!)

#to_resultResult::Success

Converts to Result::Success

Returns:



425
# File 'lib/dry/monads/result.rb', line 425

def to_result = Result.pure(value!)

#value!Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Extracts the value

Returns:

  • (Object)


66
# File 'lib/dry/monads/validated.rb', line 66

def value! = @value