Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/joker1007/nil_guard
Nil safe method chain syntax by Refinements
https://github.com/joker1007/nil_guard
Last synced: 2 days ago
JSON representation
Nil safe method chain syntax by Refinements
- Host: GitHub
- URL: https://github.com/joker1007/nil_guard
- Owner: joker1007
- License: mit
- Created: 2014-08-05T04:51:17.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-08-05T04:51:41.000Z (over 10 years ago)
- Last Synced: 2024-04-15T22:38:40.705Z (7 months ago)
- Language: Ruby
- Homepage:
- Size: 105 KB
- Stars: 7
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# NilGuard
Nil safe method chain syntax by Refinements
## Installation
Add this line to your application's Gemfile:
gem 'nil_guard', github: 'joker1007/nil_guard'
And then execute:
$ bundle
## Usage
```ruby
using NilGuard::Syntax# Enable obj.|.method.|.method2
[1, 2, 3].map {|n| n > 2 ? nil : n * 2}
.map {|n| n.|.to_s.|.gsub(/4/, "four")}
# => ["2", "four", nil]
```## Contributing
1. Fork it ( https://github.com/[my-github-username]/nil_guard/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request