has-guarded-handlers 1.3.1 → 1.4.0

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.0](https://github.com/adhearsion/has-guarded-handlers/compare/v1.3.1...v1.4.0) - [2012-12-08](https://rubygems.org/gems/has-guarded-handlers/versions/1.4.0)
4
+ * Feature: Return true/false from #trigger_handler depending on wether a handler was called or not
5
+
3
6
  # [1.3.1](https://github.com/adhearsion/has-guarded-handlers/compare/v1.3.0...v1.3.1) - [2012-07-19](https://rubygems.org/gems/has-guarded-handlers/versions/1.3.1)
4
7
  * Removed dependency on uuid gem in favour of the Ruby built-in `SecureRandom.uuid`
5
8
 
@@ -84,6 +84,7 @@ module HasGuardedHandlers
84
84
  handler.find do |guards, handler, tmp|
85
85
  val = catch(:pass) { call_handler handler, guards, event }
86
86
  delete_handler_if(type) { |_, h, _| h.equal? handler } if tmp && val
87
+ val
87
88
  end
88
89
  end
89
90
  end
@@ -110,7 +111,9 @@ module HasGuardedHandlers
110
111
  end
111
112
 
112
113
  def call_handler(handler, guards, event) # :nodoc:
113
- handler.call event unless guarded?(guards, event)
114
+ return if guarded?(guards, event)
115
+ handler.call event
116
+ true
114
117
  end
115
118
 
116
119
  def new_handler_id # :nodoc:
@@ -1,3 +1,3 @@
1
1
  module HasGuardedHandlers
2
- VERSION = "1.3.1"
2
+ VERSION = "1.4.0"
3
3
  end
@@ -13,8 +13,8 @@ describe HasGuardedHandlers do
13
13
  it 'can register a handler' do
14
14
  response.expects(:call).twice.with(event)
15
15
  subject.register_handler(:event) { |e| response.call e }
16
- subject.trigger_handler :event, event
17
- subject.trigger_handler :event, event
16
+ subject.trigger_handler(:event, event).should be_true
17
+ subject.trigger_handler(:event, event).should be_true
18
18
  end
19
19
 
20
20
  it 'can register a handler for all events, regardless of category' do
@@ -49,6 +49,7 @@ describe HasGuardedHandlers do
49
49
  lambda do
50
50
  subject.trigger_handler :event, event
51
51
  end.should_not raise_error
52
+ subject.trigger_handler(:event, event).should be_false
52
53
  end
53
54
 
54
55
  it 'allows for breaking out of handlers' do
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.3.1
4
+ version: 1.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-07-19 00:00:00.000000000 Z
13
+ date: 2012-12-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -160,7 +160,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
160
160
  version: '0'
161
161
  segments:
162
162
  - 0
163
- hash: 3518286049349315587
163
+ hash: 1393339349049738714
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: 3518286049349315587
172
+ hash: 1393339349049738714
173
173
  requirements: []
174
174
  rubyforge_project: has-guarded-handlers
175
175
  rubygems_version: 1.8.24