endeavour 0.0.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +37 -6
- data/lib/endeavour/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9efb61a646f24ddb802b9fe4b472fee135780745
|
4
|
+
data.tar.gz: 944e69df23747c928288cf0c09d84838b0be2043
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8da32b5f6bb5a501524643683808f1fac116bbba09d55fb56a10f9c1a36a250e9caa54bf786624f2badaeea2a472b8ea2885daeafceff67d78ba7493a83d9ca
|
7
|
+
data.tar.gz: 807220a7c68ac07de4b0b47928d02fcf6c79b16dcbe629a10fc84da5ad73df59b9684f189f9b0a0fdc288f6ddf1477efc6f90596963f8f17345051a4ae9dc048
|
data/README.md
CHANGED
@@ -1,6 +1,29 @@
|
|
1
1
|
# Endeavour
|
2
2
|
|
3
|
-
|
3
|
+
Endeavour is a simple gem that adds a `try` method to `Object` and `NilClass`
|
4
|
+
instances. `try` permits calling a method on an object and returning `nil`
|
5
|
+
rather than `NoMethodError` if the object is `nil` or does not respond to
|
6
|
+
the method.
|
7
|
+
|
8
|
+
## Usage
|
9
|
+
|
10
|
+
There are two ways to use `try`:
|
11
|
+
|
12
|
+
### 1. Call-based syntax (similar to Rails' [Object#try](http://api.rubyonrails.org/classes/Object.html#method-i-try))
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
car.try(:drive)
|
16
|
+
|
17
|
+
colors.try(:[], :red)
|
18
|
+
```
|
19
|
+
|
20
|
+
### 1. Delegate syntax (inspired by [HoboSupport](http://www.hobocentral.net/manual/hobo_support))
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
car.try.drive
|
24
|
+
|
25
|
+
colors.try[:red]
|
26
|
+
```
|
4
27
|
|
5
28
|
## Installation
|
6
29
|
|
@@ -18,12 +41,20 @@ Or install it yourself as:
|
|
18
41
|
|
19
42
|
$ gem install endeavour
|
20
43
|
|
21
|
-
|
44
|
+
### Rails applications
|
22
45
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
46
|
+
Endeavour uses a
|
47
|
+
[Railtie](http://api.rubyonrails.org/classes/Rails/Railtie.html) and can be
|
48
|
+
used after initialization without additional configuration.
|
49
|
+
|
50
|
+
### Non-Rails applications
|
51
|
+
|
52
|
+
Call `Endeavour.hook!` early in your application.
|
53
|
+
|
54
|
+
### Remove Endeavour
|
55
|
+
|
56
|
+
In some cases, you may want to remove Endeavour (say, if a naughty gem requires
|
57
|
+
it). You can do so with `Endeavour.remove_hook!`
|
27
58
|
|
28
59
|
## Contributing
|
29
60
|
|
data/lib/endeavour/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: endeavour
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cory Kaufman-Schofield
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest-reporters
|