Releases: rap1ds/ruby-possibly
v1.0.1
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
v0.2.0
Adds threequals ===
operator. This allows Maybe to be used in case expressions. See README for more information.
This release also moves Some and None classes to top-level. They are not anymore wrapped in Maybe module (Maybe::Some, Maybe::None). Also Maybe is now a top-level class, not a module. This change pollutes the global namespace a bit more, but it is required for the case expressions where it is nicer to compare to Some
than to Maybe::Some
.
When updating, there shouldn't be any breaking changes if you haven't referenced to Maybe::Some
or Maybe::None
directly or used None
constant.