activerecord-committed_observer 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,40 @@ require "activerecord-committed_observer/version"
3
3
  module ActiveRecord
4
4
  module CommittedObserver
5
5
 
6
+ def self.included(klass)
7
+ klass.class_eval do
8
+ def self.method_added(method_name)
9
+ super
10
+
11
+ if method_name.to_sym == :after_commit
12
+ ::ActiveRecord::CommittedObserver.warn_after_commit_override
13
+ end
14
+ end
15
+ end
16
+
17
+ if klass.method_defined?(:after_commit)
18
+ ::ActiveRecord::CommittedObserver.warn_after_commit_override
19
+ end
20
+ end
21
+
22
+ def self.warn_after_commit_override
23
+ if Rails.env != 'production'
24
+ warn <<-SUPER_WARN
25
+ If you are using ActiveRecord::CommittedObserver and defined an :after_commit
26
+ method make sure you call super to have the after_commit_on* series of methods
27
+ called.
28
+
29
+ Instead of :after_commit you can also define :after_commit_on_commit for the
30
+ same functionality without the 'warn' message.
31
+
32
+ ^ after_commit_on_commit will be called before any other after_commit_on_* methods
33
+ SUPER_WARN
34
+ end
35
+ end
36
+
6
37
  def after_commit(model)
38
+ after_commit_on_commit(model) if respond_to?(:after_commit_on_commit)
39
+
7
40
  case
8
41
  when model.__send__(:transaction_include_action?, :create) then
9
42
  after_commit_on_create(model) if respond_to?(:after_commit_on_create)
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module CommittedObserver
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-committed_observer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -105,7 +105,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
105
105
  version: '0'
106
106
  segments:
107
107
  - 0
108
- hash: -1599640367166130406
108
+ hash: -2426906980120928468
109
109
  required_rubygems_version: !ruby/object:Gem::Requirement
110
110
  none: false
111
111
  requirements:
@@ -114,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
114
  version: '0'
115
115
  segments:
116
116
  - 0
117
- hash: -1599640367166130406
117
+ hash: -2426906980120928468
118
118
  requirements: []
119
119
  rubyforge_project:
120
120
  rubygems_version: 1.8.24