Class: Mooset::Many
Instance Attribute Summary collapse
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Class Method Summary collapse
Instance Method Summary collapse
- #and_then(&block) ⇒ Object
-
#initialize(values) ⇒ Many
constructor
A new instance of Many.
Methods included from Monad
Constructor Details
#initialize(values) ⇒ Many
Returns a new instance of Many.
62 63 64 |
# File 'lib/mooset/monads.rb', line 62 def initialize(values) @values = values end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Mooset::Monad
Instance Attribute Details
#values ⇒ Object (readonly)
Returns the value of attribute values.
60 61 62 |
# File 'lib/mooset/monads.rb', line 60 def values @values end |
Class Method Details
.from_value(value) ⇒ Object
72 73 74 |
# File 'lib/mooset/monads.rb', line 72 def self.from_value(value) Many.new([value]) end |
Instance Method Details
#and_then(&block) ⇒ Object
66 67 68 69 70 |
# File 'lib/mooset/monads.rb', line 66 def and_then(&block) block = ensure_monadic_result(&block) Many.new(values.map(&block).flat_map(&:values)) end |