active_model_listener 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,4 @@
1
1
  2009-10-26
2
2
  - you no longer have to define all 3 callback methods in callback classes
3
- - callback methods are execute without listeners, to prevent recursion
3
+ - callback methods are execute without listeners, to prevent recursion
4
+ - inherited subclasses don't get two copies of the callbacks
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 0.2.3
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{active_model_listener}
8
- s.version = "0.2.2"
8
+ s.version = "0.2.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jeff Dean"]
@@ -4,24 +4,16 @@ require 'active_model_listener/active_model_listener'
4
4
  module WireUpModels
5
5
 
6
6
  def self.included(base)
7
- base.send(:extend, ClassMethods)
8
- end
9
-
10
- module ClassMethods
11
- def inherited(child)
12
- super
13
-
14
- child.after_create do |record|
15
- ActiveModelListener.dispatch record, :create
16
- end
7
+ base.after_create do |record|
8
+ ActiveModelListener.dispatch record, :create
9
+ end
17
10
 
18
- child.after_update do |record|
19
- ActiveModelListener.dispatch record, :update
20
- end
11
+ base.after_update do |record|
12
+ ActiveModelListener.dispatch record, :update
13
+ end
21
14
 
22
- child.after_destroy do |record|
23
- ActiveModelListener.dispatch record, :destroy
24
- end
15
+ base.after_destroy do |record|
16
+ ActiveModelListener.dispatch record, :destroy
25
17
  end
26
18
  end
27
19
 
@@ -28,6 +28,9 @@ describe ActiveModelListener do
28
28
  string :title
29
29
  end
30
30
 
31
+ build_model :editorials, :superclass => Article do
32
+ end
33
+
31
34
  ActiveModelListener.listeners.clear
32
35
  ActiveModelListener.listeners << FooListener
33
36
  ActiveModelListener.listeners << BarListener
@@ -70,6 +73,11 @@ describe ActiveModelListener do
70
73
  FooListener.should_receive(:after_create).once
71
74
  Article.create! :title => "foo"
72
75
  end
76
+
77
+ it "should not be run twice for inherited models" do
78
+ FooListener.should_receive(:after_create).once
79
+ Editorial.create! :title => "foo"
80
+ end
73
81
  end
74
82
 
75
83
  describe "after create" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_model_listener
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Dean