lib/zx/maybe.rb in zx-monads-0.0.6 vs lib/zx/maybe.rb in zx-monads-0.0.7
- old
+ new
@@ -171,29 +171,32 @@
self
end
end
module ClassMethods
- None = ->(*kwargs) { Zx::Maybe::None.new(*kwargs) }
+ None = ->(value = nil) { Zx::Maybe::None.new(value) }
Some = ->(*kwargs) { Zx::Maybe::Some.new(*kwargs) }
Maybe = ->(*kwargs) { Zx::Maybe.of(*kwargs) }
def Maybe(*kwargs)
- Zx::Maybe.of(*kwargs)
+ Maybe[*kwargs]
end
def Some(*kwargs)
- Zx::Maybe::Some.new(*kwargs)
+ Some[*kwargs]
end
- def None(*kwargs)
- Zx::Maybe::None.new(*kwargs)
+ def None(value = nil)
+ Zx::Maybe.of(value)
end
def Try(default = nil, options = {})
Some[yield]
rescue StandardError => e
None[default || options.fetch(:or, nil)]
end
end
end
+
+ include Maybe::ClassMethods
+ extend Maybe::ClassMethods
end