watchable 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,24 +4,24 @@ module Watchable
4
4
  end
5
5
 
6
6
  def fire event, *args
7
- watchers[event].each { |w| w && w.call(*args) }
8
- watchers[:all].each { |w| w && w.call(event, *args) }
7
+ watchers[event].each { |w| w.call *args }
8
+ watchers[:all].each { |w| w.call event, *args }
9
9
 
10
10
  self
11
11
  end
12
12
 
13
- def on event, callable = nil, &block
14
- watchers[event] << (callable || block)
13
+ def on event, callable = Proc.new
14
+ watchers[event] << callable
15
15
 
16
16
  self
17
17
  end
18
18
 
19
- def once event, callable = nil, &block
19
+ def once event, callable = Proc.new
20
20
  wrapper = lambda do |*args|
21
21
  off event, wrapper
22
- (callable || block).call *args
22
+ callable.call *args
23
23
  end
24
-
24
+
25
25
  on event, wrapper
26
26
  end
27
27
 
@@ -31,11 +31,6 @@ describe Watchable do
31
31
  @obj.fire :foo
32
32
  end
33
33
 
34
- it "ignores nil watchers" do
35
- @obj.on :foo, nil
36
- @obj.fire :foo
37
- end
38
-
39
34
  it "returns the watchable" do
40
35
  assert_same @obj, @obj.fire(:foo)
41
36
  end
@@ -9,7 +9,7 @@ Gem::Specification.new do |gem|
9
9
  gem.test_files = `git ls-files -- test/*`.split "\n"
10
10
  gem.name = "watchable"
11
11
  gem.require_paths = ["lib"]
12
- gem.version = "0.0.0"
12
+ gem.version = "0.0.1"
13
13
 
14
14
  gem.add_development_dependency "minitest"
15
15
  gem.add_development_dependency "mocha"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: watchable
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 0
10
- version: 0.0.0
9
+ - 1
10
+ version: 0.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - John Barnette