callback 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGES CHANGED
@@ -1,5 +1,8 @@
1
+ 2006-11-25 (0.3.2)
2
+ * Added CallbackContainer#clear method
3
+
1
4
  2006-11-24 (0.3.1)
2
- * callback :name results in the callback name rather than on_name
5
+ * Callback :name results in the callback name rather than on_name
3
6
 
4
7
  2006-11-24 (0.3.0)
5
8
  * Added Module#callback method. Also added all of the callback methods into Object.
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ require 'rake/clean'
5
5
  require 'rake/rdoctask'
6
6
 
7
7
  PKG_NAME = "callback"
8
- PKG_VERSION = "0.3.1"
8
+ PKG_VERSION = "0.3.2"
9
9
  PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
10
10
  PKG_FILES = FileList[
11
11
  '[A-Z]*',
@@ -25,7 +25,6 @@ module Callback
25
25
  callbacks.notify(key, *args, &error_handler)
26
26
  end
27
27
 
28
- private
29
28
  def callbacks
30
29
  @callbacks ||= CallbackContainer.new
31
30
  end
@@ -32,6 +32,10 @@ module Callback
32
32
  end
33
33
  end
34
34
 
35
+ def clear
36
+ @callback_registry.clear
37
+ end
38
+
35
39
  protected
36
40
  def extract_callback(first_choice_callback, second_choice_callback = nil)
37
41
  callback = nil
@@ -0,0 +1,28 @@
1
+ dir = File.dirname(__FILE__)
2
+ require "#{dir}/spec_helper"
3
+
4
+ context "A CallbackContainer instance" do
5
+ setup do
6
+ @container = Callback::CallbackContainer.new
7
+ end
8
+
9
+ specify "should define and call callbacks" do
10
+ @container.define(:foo) {:bar}
11
+ @container.define(:foo) {:baz}
12
+ @container.notify(:foo).should == [:bar, :baz]
13
+ end
14
+
15
+ specify "should undefine callbacks" do
16
+ callback_to_undefine = @container.define(:foo) {:bar}
17
+ @container.define(:foo) {:baz}
18
+ @container.undefine(:foo, callback_to_undefine)
19
+ @container.notify(:foo).should == [:baz]
20
+ end
21
+
22
+ specify "should clear all callbacks" do
23
+ @container.define(:foo) {:bar}
24
+ @container.define(:baz) {1}
25
+ @container.clear
26
+ @container.notify(:foo).should == []
27
+ end
28
+ end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: callback
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.3.1
7
- date: 2006-11-24 00:00:00 -08:00
6
+ version: 0.3.2
7
+ date: 2006-11-25 00:00:00 -08:00
8
8
  summary: A simple callback library for ruby objects.
9
9
  require_paths:
10
10
  - lib
@@ -41,9 +41,11 @@ files:
41
41
  - spec/module_spec.rb
42
42
  - spec/spec_helper.rb
43
43
  - spec/spec_suite.rb
44
+ - spec/callback_container_spec.rb
44
45
  - spec/object_spec.rb
45
46
  test_files:
46
47
  - spec/module_spec.rb
48
+ - spec/callback_container_spec.rb
47
49
  - spec/object_spec.rb
48
50
  rdoc_options: []
49
51