Method: Monadic::Either.unit
- Defined in:
- lib/monadic/either.rb
.unit(value) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/monadic/either.rb', line 9 def self.unit(value) return value if value.is_a? Either return Nothing if value.is_a? Nothing return Success.new(value.fetch) if value.is_a? Just return Failure.new(value) if value.nil? || (value.respond_to?(:empty?) && value.empty?) || !value return Success.new(value) end |