has-guarded-handlers 1.4.1 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,8 @@
1
1
  # [develop](https://github.com/adhearsion/has-guarded-handlers)
2
2
 
3
+ # [1.4.2](https://github.com/adhearsion/has-guarded-handlers/compare/v1.4.1...v1.4.2) - [2012-12-08](https://rubygems.org/gems/has-guarded-handlers/versions/1.4.2)
4
+ * Bugfix: Preserve the old 'API' by which handlers were called
5
+
3
6
  # [1.4.1](https://github.com/adhearsion/has-guarded-handlers/compare/v1.4.0...v1.4.1) - [2012-12-08](https://rubygems.org/gems/has-guarded-handlers/versions/1.4.1)
4
7
  * Bugfix: Report handler execution correctly in edge cases
5
8
 
@@ -88,7 +88,7 @@ module HasGuardedHandlers
88
88
  if guarded?(guards, event)
89
89
  called = false
90
90
  else
91
- handler.call event
91
+ call_handler handler, event
92
92
  true
93
93
  end
94
94
  end
@@ -101,6 +101,10 @@ module HasGuardedHandlers
101
101
 
102
102
  private
103
103
 
104
+ def call_handler(handler, event)
105
+ handler.call event
106
+ end
107
+
104
108
  def delete_handler_if(type, &block) # :nodoc:
105
109
  guarded_handlers[type].each_pair do |priority, handlers|
106
110
  handlers.delete_if(&block)
@@ -1,3 +1,3 @@
1
1
  module HasGuardedHandlers
2
- VERSION = "1.4.1"
2
+ VERSION = "1.4.2"
3
3
  end
@@ -68,6 +68,20 @@ describe HasGuardedHandlers do
68
68
  subject.trigger_handler(:event, event).should be_true
69
69
  end
70
70
 
71
+ context 'when multiple handlers are registered' do
72
+ it "stops at the first matching handler regardless of return value" do
73
+ response.expects(:handle).once
74
+ subject.register_handler :event do |_|
75
+ response.handle
76
+ false
77
+ end
78
+ subject.register_handler :event do |_|
79
+ response.handle
80
+ end
81
+ subject.trigger_handler(:event, event).should be_true
82
+ end
83
+ end
84
+
71
85
  it 'allows for passing to the next handler of the same type' do
72
86
  response.expects(:handle1).once
73
87
  response.expects(:handle2).once
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has-guarded-handlers
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -160,7 +160,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
160
160
  version: '0'
161
161
  segments:
162
162
  - 0
163
- hash: -1217172567679436302
163
+ hash: 1044728951483733350
164
164
  required_rubygems_version: !ruby/object:Gem::Requirement
165
165
  none: false
166
166
  requirements:
@@ -169,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
169
  version: '0'
170
170
  segments:
171
171
  - 0
172
- hash: -1217172567679436302
172
+ hash: 1044728951483733350
173
173
  requirements: []
174
174
  rubyforge_project: has-guarded-handlers
175
175
  rubygems_version: 1.8.24