hooks 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.textile CHANGED
@@ -1,12 +1,17 @@
1
+ h2. 0.2.2
2
+
3
+ * `#run_hook` now returns the list of callback results.
4
+
1
5
  h2. 0.2.1
6
+
2
7
  * You can now pass multiple hook names to @#define_hooks@.
3
8
 
4
9
  h2. 0.2.0
5
10
 
6
11
  h3. Changes
7
- * Callback blocks are now executed on the instance using @instance_exec@. If you need to access the class (former context) use @self.class@.
12
+ * Callback blocks are now executed on the instance using @instance_exec@. If you need to access the class (former context) use @self.class@.
8
13
 
9
14
  h2. 0.1.4
10
15
 
11
16
  h3. Bugfixes
12
- * An uninitialized @inheritable_attr@ doesn't crash since it is not cloned anymore. Note that an uncloneable attribute value still causes an exception.
17
+ * An uninitialized @inheritable_attr@ doesn't crash since it is not cloned anymore. Note that an uncloneable attribute value still causes an exception.
data/lib/hooks.rb CHANGED
@@ -17,7 +17,7 @@ require "hooks/inheritable_attribute"
17
17
  #
18
18
  # cat.run_hook :after_dinner
19
19
  module Hooks
20
- VERSION = "0.2.1"
20
+ VERSION = "0.2.2"
21
21
 
22
22
  def self.included(base)
23
23
  base.extend InheritableAttribute
@@ -47,7 +47,7 @@ module Hooks
47
47
  end
48
48
 
49
49
  def run_hook_for(name, scope, *args)
50
- callbacks_for_hook(name).each do |callback|
50
+ callbacks_for_hook(name).map do |callback|
51
51
  if callback.kind_of? Symbol
52
52
  scope.send(callback, *args)
53
53
  else
data/test/hooks_test.rb CHANGED
@@ -87,6 +87,15 @@ class HooksTest < Test::Unit::TestCase
87
87
  @mum.run_hook(:after_eight)
88
88
  assert_equal [:c], @mum.executed
89
89
  end
90
+
91
+ should "return callback results in order" do
92
+ @mum.class.after_eight { :dinner_out }
93
+ @mum.class.after_eight { :party_hard }
94
+ @mum.class.after_eight { :taxi_home }
95
+
96
+ results = @mum.run_hook(:after_eight)
97
+ assert_equal [:dinner_out, :party_hard, :taxi_home], results
98
+ end
90
99
  end
91
100
 
92
101
  context "in class context" do
@@ -141,7 +150,7 @@ class HooksTest < Test::Unit::TestCase
141
150
  end
142
151
  end.new
143
152
 
144
- assert_equal [:take_shower, :have_dinner], @kid.run_hook(:after_eight)
153
+ assert_equal [:take_shower, :have_dinner], @kid.class.callbacks_for_hook(:after_eight)
145
154
  end
146
155
  end
147
156
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hooks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-03 00:00:00.000000000 Z
12
+ date: 2012-11-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: shoulda
@@ -85,7 +85,4 @@ rubygems_version: 1.8.24
85
85
  signing_key:
86
86
  specification_version: 3
87
87
  summary: Generic hooks with callbacks for Ruby.
88
- test_files:
89
- - test/hooks_test.rb
90
- - test/inheritable_attribute_test.rb
91
- - test/test_helper.rb
88
+ test_files: []