First 1.x release!
This release is the first 1.x release, which marks that the project is now officially production ready. The gem is battle tested in real life. We at Sharetribe have been using the gem in our production application since the first version without any issues. In addition to that, the public API of the gem hasn't seen any radical breaking changes for long time, so it's now great time to release the first 1.x version.
What's new?
-
Added
or_raise
or_raise
returns an unwrapped value forSome
and throws an exception forNone
. The exception message helps you to spot where the object becameNone
.users = Maybe({users: [{name: {first: "John", last: "Doe"}}]}) users[:users][0][:name][:first].or_raise # => "John" users[:users][1][:name][:first].or_raise # => None::ValueExpectedException: `or_raise` called to None. A value was expected. # => Maybe => Some({:users=>[{:name=>{:first=>"John", :last=>"Doe"}}]}) # => [:users] => Some([{:name=>{:first=>"John", :last=>"Doe"}}]) # => [1] => None # => [:name] => None # => [:first] => None
-
Added
or_nil
or_nil
returns an unwrapped value forSome
andnil
forNone
. It's equivalent to.or_else(nil)
users = Maybe({users: [{name: {first: "John", last: "Doe"}}]}) users[:users][0][:name][:first].or_nil # => "John" users[:users][1][:name][:first].or_nil # => nil