has-guarded-handlers 0.1.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/CHANGELOG.md +6 -0
- data/lib/has_guarded_handlers.rb +2 -2
- data/lib/has_guarded_handlers/version.rb +1 -1
- data/spec/has_guarded_handlers_spec.rb +13 -1
- metadata +23 -19
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
data/lib/has_guarded_handlers.rb
CHANGED
@@ -68,7 +68,7 @@ module HasGuardedHandlers
|
|
68
68
|
def guarded?(guards, event)
|
69
69
|
guards.find do |guard|
|
70
70
|
case guard
|
71
|
-
when Class
|
71
|
+
when Class, Module
|
72
72
|
!event.is_a? guard
|
73
73
|
when Symbol
|
74
74
|
!event.__send__ guard
|
@@ -99,7 +99,7 @@ module HasGuardedHandlers
|
|
99
99
|
case guard
|
100
100
|
when Array
|
101
101
|
guard.each { |g| check_guards [g] }
|
102
|
-
when Class, Symbol, Proc, Hash, String
|
102
|
+
when Class, Module, Symbol, Proc, Hash, String
|
103
103
|
nil
|
104
104
|
else
|
105
105
|
raise "Bad guard: #{guard.inspect}"
|
@@ -100,8 +100,12 @@ describe TestObject do
|
|
100
100
|
end
|
101
101
|
|
102
102
|
describe 'guards' do
|
103
|
+
GuardMixin = Module.new
|
104
|
+
class GuardedObject
|
105
|
+
include GuardMixin
|
106
|
+
end
|
107
|
+
|
103
108
|
it 'can be a class' do
|
104
|
-
class GuardedObject; end
|
105
109
|
response.expects(:call).once
|
106
110
|
subject.register_handler(:event, GuardedObject) { |_| response.call }
|
107
111
|
|
@@ -109,6 +113,14 @@ describe TestObject do
|
|
109
113
|
subject.trigger_handler :event, Object.new
|
110
114
|
end
|
111
115
|
|
116
|
+
it 'can be a module' do
|
117
|
+
response.expects(:call).once
|
118
|
+
subject.register_handler(:event, GuardMixin) { |_| response.call }
|
119
|
+
|
120
|
+
subject.trigger_handler :event, GuardedObject.new
|
121
|
+
subject.trigger_handler :event, Object.new
|
122
|
+
end
|
123
|
+
|
112
124
|
it 'can be a symbol' do
|
113
125
|
response.expects(:call).once
|
114
126
|
subject.register_handler(:event, :chat?) { |_| response.call }
|
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: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,12 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
14
|
-
default_executable:
|
13
|
+
date: 2012-01-19 00:00:00.000000000 Z
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
17
16
|
name: bundler
|
18
|
-
requirement: &
|
17
|
+
requirement: &2169268020 !ruby/object:Gem::Requirement
|
19
18
|
none: false
|
20
19
|
requirements:
|
21
20
|
- - ~>
|
@@ -23,10 +22,10 @@ dependencies:
|
|
23
22
|
version: 1.0.0
|
24
23
|
type: :development
|
25
24
|
prerelease: false
|
26
|
-
version_requirements: *
|
25
|
+
version_requirements: *2169268020
|
27
26
|
- !ruby/object:Gem::Dependency
|
28
27
|
name: rspec
|
29
|
-
requirement: &
|
28
|
+
requirement: &2169267440 !ruby/object:Gem::Requirement
|
30
29
|
none: false
|
31
30
|
requirements:
|
32
31
|
- - ! '>='
|
@@ -34,10 +33,10 @@ dependencies:
|
|
34
33
|
version: 2.5.0
|
35
34
|
type: :development
|
36
35
|
prerelease: false
|
37
|
-
version_requirements: *
|
36
|
+
version_requirements: *2169267440
|
38
37
|
- !ruby/object:Gem::Dependency
|
39
38
|
name: mocha
|
40
|
-
requirement: &
|
39
|
+
requirement: &2169266940 !ruby/object:Gem::Requirement
|
41
40
|
none: false
|
42
41
|
requirements:
|
43
42
|
- - ! '>='
|
@@ -45,10 +44,10 @@ dependencies:
|
|
45
44
|
version: '0'
|
46
45
|
type: :development
|
47
46
|
prerelease: false
|
48
|
-
version_requirements: *
|
47
|
+
version_requirements: *2169266940
|
49
48
|
- !ruby/object:Gem::Dependency
|
50
49
|
name: ci_reporter
|
51
|
-
requirement: &
|
50
|
+
requirement: &2169266380 !ruby/object:Gem::Requirement
|
52
51
|
none: false
|
53
52
|
requirements:
|
54
53
|
- - ! '>='
|
@@ -56,10 +55,10 @@ dependencies:
|
|
56
55
|
version: 1.6.3
|
57
56
|
type: :development
|
58
57
|
prerelease: false
|
59
|
-
version_requirements: *
|
58
|
+
version_requirements: *2169266380
|
60
59
|
- !ruby/object:Gem::Dependency
|
61
60
|
name: yard
|
62
|
-
requirement: &
|
61
|
+
requirement: &2169265860 !ruby/object:Gem::Requirement
|
63
62
|
none: false
|
64
63
|
requirements:
|
65
64
|
- - ~>
|
@@ -67,10 +66,10 @@ dependencies:
|
|
67
66
|
version: 0.7.0
|
68
67
|
type: :development
|
69
68
|
prerelease: false
|
70
|
-
version_requirements: *
|
69
|
+
version_requirements: *2169265860
|
71
70
|
- !ruby/object:Gem::Dependency
|
72
71
|
name: rake
|
73
|
-
requirement: &
|
72
|
+
requirement: &2169265320 !ruby/object:Gem::Requirement
|
74
73
|
none: false
|
75
74
|
requirements:
|
76
75
|
- - ! '>='
|
@@ -78,10 +77,10 @@ dependencies:
|
|
78
77
|
version: '0'
|
79
78
|
type: :development
|
80
79
|
prerelease: false
|
81
|
-
version_requirements: *
|
80
|
+
version_requirements: *2169265320
|
82
81
|
- !ruby/object:Gem::Dependency
|
83
82
|
name: guard-rspec
|
84
|
-
requirement: &
|
83
|
+
requirement: &2169264900 !ruby/object:Gem::Requirement
|
85
84
|
none: false
|
86
85
|
requirements:
|
87
86
|
- - ! '>='
|
@@ -89,7 +88,7 @@ dependencies:
|
|
89
88
|
version: '0'
|
90
89
|
type: :development
|
91
90
|
prerelease: false
|
92
|
-
version_requirements: *
|
91
|
+
version_requirements: *2169264900
|
93
92
|
description: Allow an object's API to provide flexible handler registration, storage
|
94
93
|
and matching to arbitrary events.
|
95
94
|
email:
|
@@ -111,7 +110,6 @@ files:
|
|
111
110
|
- lib/has_guarded_handlers/version.rb
|
112
111
|
- spec/has_guarded_handlers_spec.rb
|
113
112
|
- spec/spec_helper.rb
|
114
|
-
has_rdoc: true
|
115
113
|
homepage: http://github.com/adhearsion/has-guarded-handlers
|
116
114
|
licenses: []
|
117
115
|
post_install_message:
|
@@ -124,15 +122,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
124
122
|
- - ! '>='
|
125
123
|
- !ruby/object:Gem::Version
|
126
124
|
version: '0'
|
125
|
+
segments:
|
126
|
+
- 0
|
127
|
+
hash: -748980547343976584
|
127
128
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
129
|
none: false
|
129
130
|
requirements:
|
130
131
|
- - ! '>='
|
131
132
|
- !ruby/object:Gem::Version
|
132
133
|
version: '0'
|
134
|
+
segments:
|
135
|
+
- 0
|
136
|
+
hash: -748980547343976584
|
133
137
|
requirements: []
|
134
138
|
rubyforge_project: has-guarded-handlers
|
135
|
-
rubygems_version: 1.
|
139
|
+
rubygems_version: 1.8.10
|
136
140
|
signing_key:
|
137
141
|
specification_version: 3
|
138
142
|
summary: A library for associating a set of event handlers, complete with guards,
|