hooks 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,25 @@
1
+ ## 0.3.1
2
+
3
+ * Fix a bug, string hook names are now treated as symbols.
4
+
5
+ ## 0.3.0
6
+
7
+ * The callback chain can now be halted by configuring the hook as `halts_on_falsey: true` and returning `nil` or `false` from the callback.
8
+ * Internal refactorings: hooks are now encapsulated in `Hook` instances and run their callback chains.
9
+
10
+ ## 0.2.2
11
+
12
+ * `#run_hook` now returns the list of callback results.
13
+
14
+ ## 0.2.1
15
+
16
+ * You can now pass multiple hook names to `#define_hooks`.
17
+
18
+ ## 0.2.0
19
+
20
+ h3. Changes
21
+ * Callback blocks are now executed on the instance using `instance_exec`. If you need to access the class (former context) use `self.class`.
22
+
23
+ ## 0.1.4
24
+
25
+ * An uninitialized `inheritable_attr` doesn't crash since it is not cloned anymore. Note that an uncloneable attribute value still causes an exception.
@@ -18,7 +18,7 @@ require "hooks/hook"
18
18
  #
19
19
  # cat.run_hook :after_dinner
20
20
  module Hooks
21
- VERSION = "0.3.0"
21
+ VERSION = "0.3.1"
22
22
 
23
23
  def self.included(base)
24
24
  base.class_eval do
@@ -107,6 +107,14 @@ module Hooks
107
107
  end
108
108
 
109
109
  class HookSet < Hash
110
+ def [](name)
111
+ super(name.to_sym)
112
+ end
113
+
114
+ def []=(name, values)
115
+ super(name.to_sym, values)
116
+ end
117
+
110
118
  def clone
111
119
  super.tap do |cloned|
112
120
  each { |name, callbacks| cloned[name] = callbacks.clone }
@@ -25,6 +25,13 @@ class HooksTest < MiniTest::Spec
25
25
  assert_equal [:dine], klass.callbacks_for_hook(:after_eight)
26
26
  end
27
27
 
28
+ it 'symbolizes strings when defining a hook' do
29
+ subject.class.define_hooks :before_one, 'after_one'
30
+ assert_equal [], klass.callbacks_for_hook(:before_one)
31
+ assert_equal [], klass.callbacks_for_hook(:after_one)
32
+ assert_equal [], klass.callbacks_for_hook('after_one')
33
+ end
34
+
28
35
  it "accept multiple hook names" do
29
36
  subject.class.define_hooks :before_ten, :after_ten
30
37
  assert_equal [], klass.callbacks_for_hook(:before_ten)
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.3.0
4
+ version: 0.3.1
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: 2013-05-25 00:00:00.000000000 Z
12
+ date: 2013-05-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
@@ -69,7 +69,7 @@ extra_rdoc_files: []
69
69
  files:
70
70
  - .gitignore
71
71
  - .travis.yml
72
- - CHANGES.textile
72
+ - CHANGES.md
73
73
  - Gemfile
74
74
  - README.md
75
75
  - Rakefile
@@ -1,22 +0,0 @@
1
- h2 0.3.0
2
-
3
- * The callback chain can now be halted by configuring the hook as @halts_on_falsey: true@ and returning @nil@ or @false@ from the callback.
4
- * Internal refactorings: hooks are now encapsulated in @Hook@ instances and run their callback chains.
5
-
6
- h2. 0.2.2
7
-
8
- * `#run_hook` now returns the list of callback results.
9
-
10
- h2. 0.2.1
11
-
12
- * You can now pass multiple hook names to @#define_hooks@.
13
-
14
- h2. 0.2.0
15
-
16
- h3. Changes
17
- * Callback blocks are now executed on the instance using @instance_exec@. If you need to access the class (former context) use @self.class@.
18
-
19
- h2. 0.1.4
20
-
21
- h3. Bugfixes
22
- * An uninitialized @inheritable_attr@ doesn't crash since it is not cloned anymore. Note that an uncloneable attribute value still causes an exception.