Module: Zx::Either::Eitherable
- Defined in:
- lib/zx/either.rb
Constant Summary collapse
- Left =
->(*kwargs) { ::Either::Left.new(*kwargs) }
- Right =
->(*kwargs) { ::Either::Right.new(*kwargs) }
Instance Method Summary collapse
Instance Method Details
#Left(*kwargs) ⇒ Object
12 13 14 |
# File 'lib/zx/either.rb', line 12 def Left(*kwargs) ::Either::Left.new(*kwargs) end |
#Right(*kwargs) ⇒ Object
8 9 10 |
# File 'lib/zx/either.rb', line 8 def Right(*kwargs) ::Either::Right.new(*kwargs) end |
#Try(default = nil, options = {}) ⇒ Object
16 17 18 19 20 |
# File 'lib/zx/either.rb', line 16 def Try(default = nil, = {}) Right yield rescue StandardError => e Left default || .fetch(:or, nil) end |