Skip to content

v1.0.1

Latest
Compare
Choose a tag to compare
@rap1ds rap1ds released this 24 Jul 20:11

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 for Some and throws an exception for None. The exception message helps you to spot where the object became None.

    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 for Some and nil for None. 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