Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/joker1007/maybe-chain
In method chain, This gem makes failure more graceful
https://github.com/joker1007/maybe-chain
Last synced: 2 days ago
JSON representation
In method chain, This gem makes failure more graceful
- Host: GitHub
- URL: https://github.com/joker1007/maybe-chain
- Owner: joker1007
- License: mit
- Created: 2012-11-06T20:44:56.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2012-11-22T05:15:23.000Z (almost 12 years ago)
- Last Synced: 2024-10-20T06:32:01.487Z (19 days ago)
- Language: Ruby
- Size: 153 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# maybe-chain
[![Build Status](https://secure.travis-ci.org/joker1007/maybe-chain.png?branch=master)](https://travis-ci.org/joker1007/maybe-chain)
## InstallationAdd this line to your application's Gemfile:
gem 'maybe-chain'
And then execute:
$ bundle
Or install it yourself as:
$ gem install maybe-chain
## Usage
```ruby
m1 = "a".to_maybe.upcase.gsub(/A/, "B")maybe(m1) do |str|
puts str # => B
endm2 = nil.to_maybe.upcase.gsub(/A/, "B")
maybe(m2) do |str|
puts str # No Execute
endmaybe(m2, "a") do |str|
puts str # => a
endm3 = [1,2,3].to_maybe.map {|i| i * 2}.reject {|i| i > 5}
maybe(m3) do |arr|
p arr # => [2, 4]
endm4 = "a".to_maybe(NoMethodError).upcase.no_method.gsub(/A/, "B")
maybe(m4) do |str|
puts str # => No Execute
end
```## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Added some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request