yitznewton/maybe-ruby — pull request #2 by seven1m (2014-11-11 02:19:45+00:00)
Title: Changes to allow more succinct syntax

@yitznewton @robincurry for discussion...

* Add `Maybe()` method to Kernel namespace
* Add `method_missing` support for more compact chaining of method calls

These two changes make it so this pattern is a useful replacement for my go-to [try()](http://api.rubyonrails.org/classes/Object.html#method-i-try), allowing for:

```ruby
Maybe(@current_user).profile.real_name.downcase.value_or { 'Not logged in' }
```

(Though I realize diving this deep into an object is likely a Demeter violation, this is likely an improvement over chaining `try()`s together.)