nil_conditional 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +11 -12
  3. data/nil_conditional.gemspec +2 -2
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0fc18e077b2f985f98ac155b7aa1517b02d2b0ca
4
- data.tar.gz: 807b525fb2bb0f95665213975d00b9937a4aa9e9
3
+ metadata.gz: 08e6158d09a04d23e86f9294a94739fcd1ab7e76
4
+ data.tar.gz: d4ca42ddc4fbedc67c1bff1bb3bb2f6494977b22
5
5
  SHA512:
6
- metadata.gz: b8ab231f5f82c32c5fd62b0b3f8078555049cd3d7dc5eb9a2a422d831f9ee48e32e9e819d12ae572a3ba7018af1843771265ae56a1949538f13c7d95dec35150
7
- data.tar.gz: 4e1632f12d50a069259c1ea3165d382fa4c258b6fc48252bf1ac7dc19a20e2e59a85cfdf99629c48867b43d4c0b72a0c3d85722c541d8e6cb828126e59d52ff2
6
+ metadata.gz: 9a082dfe6dc36b98f22e651fa5954d5cc423e3540650dd89d0e22ce7e6f9a1706266665d235e900fb5a7c31d2617425b72b54c0a780e9e2857475ee8a1ac2e0b
7
+ data.tar.gz: 3c72dbe3691fc3972f94b66646219adfbe8508a5e98cbd9152427bc777e1ab3b14b0e1191da3acd06647e336e41efb845a9404ac92ba43e957d85e42fb49f4b4
data/README.md CHANGED
@@ -16,7 +16,7 @@ Nil Conditional Operator is inspired by Null Conditional Operator introduced in
16
16
 
17
17
  ## Usage
18
18
 
19
- Use `?_` method as Nil Conditional Operator.
19
+ Use `_?` method as Nil Conditional Operator.
20
20
  For example: `logger._?.log('some debug information')`
21
21
 
22
22
  ```ruby
@@ -29,37 +29,36 @@ NoMethodError: undefined method `foo` for #<NilClass>
29
29
  logger._?.foo.bar.car.cow
30
30
  => #<NilConditional>
31
31
 
32
- # logger exists and all methods are valid
32
+ # logger is not nil and all corresponding methods exist
33
33
  logger._?.foo.bar.car.cow
34
34
  => "moooo"
35
35
 
36
- # logger exists and all methods are valid
37
- logger._?.foo.bar.car.cow
38
- => "moooo"
39
-
40
- # logger exists but doesn't have warn method
36
+ # logger is not nil but doesn't have warn method
41
37
  logger._?.warn('some warning')
42
38
  => #<NilConditional>
43
39
 
44
- # logger exists and have warn method, but foo is invalid
40
+ # logger is not nil and have warn method, but foo is invalid
41
+ # - first not nil value returned by receiver in train wreck breaks nil condition
45
42
  logger._?.warn('some warning').foo
46
43
  => NoMethodError: undefined method `foo`
47
44
 
45
+ # ... but you can use nil conditional again
48
46
  logger._?.warn('some warning')._?.foo
49
47
  => #<NilConditional>
50
48
 
51
- Object.new.non_existent_method
49
+ # this works also with class methods
50
+ Object.non_existent_method
52
51
  NoMethodError: undefined method `non_existent_method` for #<Object>
53
52
 
54
- Object.new._?.non_existent_method
53
+ Object._?.non_existent_method
55
54
  => #<NilConditional>
56
55
 
56
+ # NilConditional object is eql to nil
57
57
  Object.new._?.non_existent_method.nil?
58
58
  => true
59
59
  ```
60
60
 
61
- `NilConditional` instances always return new NilConditional object if method is missing.
62
- These objects are also `eql` to `nil`.
61
+ `NilConditional` instances always return new NilConditional object if method is missing. Those objects are also `eql` to `nil`.
63
62
 
64
63
 
65
64
  ## Changelog
@@ -4,11 +4,11 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'nil_conditional'
7
- spec.version = '2.0.0'
7
+ spec.version = '2.0.1'
8
8
  spec.authors = ['Grzegorz Bizon']
9
9
  spec.email = ['grzegorz.bizon@ntsn.pl']
10
10
  spec.summary = 'Nil Conditional Operator in Ruby'
11
- spec.homepage = 'http://github.com/grzesiek/nil-conditional'
11
+ spec.homepage = 'http://github.com/grzesiek/nil_conditional'
12
12
  spec.license = 'MIT'
13
13
 
14
14
  spec.files = `git ls-files -z`.split("\x0")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nil_conditional
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grzegorz Bizon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-07 00:00:00.000000000 Z
11
+ date: 2015-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -86,7 +86,7 @@ files:
86
86
  - spec/nil_spec.rb
87
87
  - spec/object_spec.rb
88
88
  - spec/spec_helper.rb
89
- homepage: http://github.com/grzesiek/nil-conditional
89
+ homepage: http://github.com/grzesiek/nil_conditional
90
90
  licenses:
91
91
  - MIT
92
92
  metadata: {}