Class: Monadist::Identity

Inherits:
Monad
  • Object
show all
Defined in:
lib/monadist/identity.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Monad

#fmap, #join, #method_missing

Constructor Details

#initialize(value) ⇒ Identity

Returns a new instance of Identity.



8
9
10
# File 'lib/monadist/identity.rb', line 8

def initialize(value)
  @value = value
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Monadist::Monad

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



4
5
6
# File 'lib/monadist/identity.rb', line 4

def value
  @value
end

Class Method Details

.unit(value) ⇒ Object



20
21
22
# File 'lib/monadist/identity.rb', line 20

def self.unit(value)
  new value
end

Instance Method Details

#bind(&block) ⇒ Object



14
15
16
# File 'lib/monadist/identity.rb', line 14

def bind(&block)
  block.call value
end