observe 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- 1.9.2-p290
1
+ 1.9.3-p0
data/README.md CHANGED
@@ -9,8 +9,8 @@ __OVERVIEW__
9
9
 
10
10
  __DESCRIPTION__
11
11
 
12
- A simple interface for adding observers to any class.
13
- The interface is similar to and takes ideas from the 'Observable' module in the Ruby standard library.
12
+ A simple interface for adding observers to any class. The interface is similar
13
+ to and takes ideas from the 'Observable' module in the Ruby standard library.
14
14
 
15
15
  __DIFFERENCES__
16
16
 
@@ -2,15 +2,17 @@ module Observe
2
2
 
3
3
  @observer = Struct.new(:group, :object)
4
4
 
5
- class << self
5
+ class << self
6
6
  attr_reader :observer
7
7
  end
8
8
 
9
9
  #
10
- # Add a observer to a class.
10
+ # Add an observer to a class.
11
11
  #
12
12
  # @example
13
- # add_observer(:group) { puts "Hello!" }
13
+ # add_observer(:group) do
14
+ # puts "Hello!"
15
+ # end
14
16
  #
15
17
  # @param [#to_sym] group
16
18
  # The name of a group that an observer belongs to.
@@ -21,25 +23,29 @@ module Observe
21
23
  # @return [void]
22
24
  #
23
25
  def add_observer group, observer=nil, &block
24
- if block_given?
25
- observers[group.to_sym] << Observe.observer.new(group.to_sym, block)
26
- elsif observer
27
- observers[group.to_sym] << Observe.observer.new(group.to_sym, observer)
26
+ obj = observer || block
27
+
28
+ if obj
29
+ group = group.to_sym
30
+ observers[group] << Observe.observer.new(group, obj)
28
31
  else
29
- raise ArgumentError, "A block or object is expected, but none given."
32
+ raise ArgumentError, "Wrong number of arguments (1 for 2)"
30
33
  end
31
34
  end
32
35
  private :add_observer
33
36
 
34
37
  #
35
- # Notify a observer.
38
+ # Notify an observer.
36
39
  #
37
40
  # @example
38
- # notify_observers :group
41
+ # notify_observers :group, "arg1", "arg2"
39
42
  #
40
43
  # @param [#to_sym] group
41
44
  # The name of a group
42
- #
45
+ #
46
+ # @param [Object] *args
47
+ # A variable number of arguments to passed onto an observer.
48
+ #
43
49
  # @return [void]
44
50
  #
45
51
  def notify_observers group, *args
@@ -50,7 +56,7 @@ module Observe
50
56
  private :notify_observers
51
57
 
52
58
  #
53
- # Destroy a observer.
59
+ # Destroy an observer.
54
60
  #
55
61
  # @example
56
62
  # destroy_observers :group
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "observe"
5
- s.version = "0.2.0"
5
+ s.version = "0.3.0"
6
6
  s.authors = ["Rob Gleeson"]
7
7
  s.email = ["rob@flowof.info"]
8
8
  s.homepage = "https://github.com/robgleeson/observe"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: observe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-02 00:00:00.000000000Z
12
+ date: 2012-02-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
16
- requirement: &70196288545480 !ruby/object:Gem::Requirement
16
+ requirement: &70127593322820 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '2.5'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70196288545480
24
+ version_requirements: *70127593322820
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &70196288544800 !ruby/object:Gem::Requirement
27
+ requirement: &70127593322320 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: 0.9.2
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70196288544800
35
+ version_requirements: *70127593322320
36
36
  description: A simple interface for adding observers to any class.
37
37
  email:
38
38
  - rob@flowof.info
@@ -66,7 +66,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
66
66
  version: '0'
67
67
  segments:
68
68
  - 0
69
- hash: 2329257265388588306
69
+ hash: 3926186142539624693
70
70
  required_rubygems_version: !ruby/object:Gem::Requirement
71
71
  none: false
72
72
  requirements:
@@ -75,10 +75,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
75
  version: '0'
76
76
  segments:
77
77
  - 0
78
- hash: 2329257265388588306
78
+ hash: 3926186142539624693
79
79
  requirements: []
80
80
  rubyforge_project: observe
81
- rubygems_version: 1.8.11
81
+ rubygems_version: 1.8.15
82
82
  signing_key:
83
83
  specification_version: 3
84
84
  summary: A simple interface for adding observers to any class.