null_object 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -9,16 +9,17 @@ Respond to ALL the things:
9
9
 
10
10
  ```ruby
11
11
  obj = NullObject.new
12
- obj.foo # => nil
13
- obj.bar # => nil
12
+ obj.foo # => obj
13
+ obj.bar # => obj
14
+ obj.foo.bar # => obj
14
15
  ```
15
16
 
16
17
  Respond to SOME of the things:
17
18
 
18
19
  ```ruby
19
20
  obj = NullObject.new(:foo, :bar)
20
- obj.foo # => nil
21
- obj.bar # => nil
21
+ obj.foo # => obj
22
+ obj.bar # => obj
22
23
  obj.baz # raises NoMethodError
23
24
  ```
24
25
 
@@ -38,12 +39,11 @@ obj.foo # => "foo"
38
39
  obj.bar # => "foo"
39
40
  ```
40
41
 
41
- Respond to ALL of the things with `self`:
42
+ Respond to ALL of the things with nil:
42
43
 
43
44
  ```ruby
44
- obj = NullObject.new { obj }
45
- obj.foo # => obj
46
- obj.foo.bar.baz # => obj
45
+ obj = NullObject.new { nil }
46
+ obj.foo # => nil
47
47
  ```
48
48
 
49
49
  ## Contributing
data/lib/null_object.rb CHANGED
@@ -36,6 +36,6 @@ class NullObject
36
36
  private
37
37
 
38
38
  def __global_return_value__
39
- @return_block && @return_block.call
39
+ @return_block ? @return_block.call : self
40
40
  end
41
41
  end
@@ -1,3 +1,3 @@
1
1
  class NullObject
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -3,14 +3,15 @@ require "spec_helper"
3
3
  describe NullObject do
4
4
  it "responds to ALL of the things" do
5
5
  obj = NullObject.new
6
- obj.foo.should be_nil
7
- obj.bar.should be_nil
6
+ obj.foo.should be obj
7
+ obj.bar.should be obj
8
+ obj.foo.bar.should be obj
8
9
  end
9
10
 
10
11
  it "responds to SOME of the things" do
11
12
  obj = NullObject.new(:foo, :bar)
12
- obj.foo.should be_nil
13
- obj.bar.should be_nil
13
+ obj.foo.should be obj
14
+ obj.bar.should be obj
14
15
  expect { obj.baz }.to raise_error(NoMethodError)
15
16
  end
16
17
 
@@ -26,9 +27,9 @@ describe NullObject do
26
27
  obj.bar.should == "foo"
27
28
  end
28
29
 
29
- it "responds to ALL of the things with `self`" do
30
- obj = NullObject.new { obj }
31
- obj.foo.should equal obj
32
- obj.foo.bar.baz.should equal obj
30
+ it "responds to ALL of the things with nil" do
31
+ obj = NullObject.new { nil }
32
+ obj.foo.should be_nil
33
+ obj.bar.should be_nil
33
34
  end
34
35
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: null_object
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-05-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70359975280920 !ruby/object:Gem::Requirement
16
+ requirement: &70364672404620 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 2.10.0
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70359975280920
24
+ version_requirements: *70364672404620
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bourne
27
- requirement: &70359975280220 !ruby/object:Gem::Requirement
27
+ requirement: &70364672403920 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.1.2
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70359975280220
35
+ version_requirements: *70364672403920
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &70359975279840 !ruby/object:Gem::Requirement
38
+ requirement: &70364672403540 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70359975279840
46
+ version_requirements: *70364672403540
47
47
  description: Dead simple library to create null objects (objects that respond to all
48
48
  messages)
49
49
  email:
@@ -77,7 +77,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
77
77
  version: '0'
78
78
  segments:
79
79
  - 0
80
- hash: -2749999320314441199
80
+ hash: -2648222180714243262
81
81
  required_rubygems_version: !ruby/object:Gem::Requirement
82
82
  none: false
83
83
  requirements:
@@ -86,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
86
  version: '0'
87
87
  segments:
88
88
  - 0
89
- hash: -2749999320314441199
89
+ hash: -2648222180714243262
90
90
  requirements: []
91
91
  rubyforge_project:
92
92
  rubygems_version: 1.8.15