disclosure 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,9 +3,11 @@ module Disclosure
3
3
  isolate_namespace Disclosure
4
4
 
5
5
  initializer 'disclosure.subscribe_to_model_events' do
6
- ActiveSupport::Notifications.subscribe "disclosure.model_saved" do |name, start, finish, id, payload|
7
- Disclosure.react_to!(payload[:model])
8
- end
6
+ Disclosure::Notifications.subscribe!
7
+ end
8
+
9
+ initializer 'disclosure.instrument_model_events' do
10
+ Disclosure::Notifications.instrument!
9
11
  end
10
12
 
11
13
  initializer 'disclosure.extend_model_classes' do
@@ -0,0 +1,23 @@
1
+ module Disclosure
2
+ module Notifications
3
+ def self.subscribe!
4
+ ActiveSupport::Notifications.subscribe "disclosure.model_saved" do |name, start, finish, id, payload|
5
+ Disclosure.react_to!(payload[:model])
6
+ end
7
+ end
8
+
9
+ def self.instrument!
10
+ Disclosure.configuration.notifier_classes.each do |klass|
11
+ klass.class_eval do
12
+ after_commit :notify_disclosure
13
+
14
+ private
15
+
16
+ def notify_disclosure
17
+ ActiveSupport::Notifications.instrument("disclosure.model_updated", :model => self)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,3 +1,3 @@
1
1
  module Disclosure
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
data/lib/disclosure.rb CHANGED
@@ -1,8 +1,11 @@
1
+ require "disclosure/notifications"
1
2
  require "disclosure/engine"
2
3
  require 'disclosure/exceptions'
3
4
  require "disclosure/configuration"
4
5
 
5
6
  module Disclosure
7
+ include Notifications
8
+
6
9
  class << self
7
10
  attr_accessor :configuration
8
11
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: disclosure
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -79,6 +79,7 @@ files:
79
79
  - lib/disclosure/configuration.rb
80
80
  - lib/disclosure/engine.rb
81
81
  - lib/disclosure/exceptions.rb
82
+ - lib/disclosure/notifications.rb
82
83
  - lib/disclosure/version.rb
83
84
  - lib/disclosure.rb
84
85
  - lib/tasks/disclosure_tasks.rake
@@ -99,7 +100,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
99
100
  version: '0'
100
101
  segments:
101
102
  - 0
102
- hash: -2082650874723204217
103
+ hash: -3608972705387088730
103
104
  required_rubygems_version: !ruby/object:Gem::Requirement
104
105
  none: false
105
106
  requirements:
@@ -108,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
109
  version: '0'
109
110
  segments:
110
111
  - 0
111
- hash: -2082650874723204217
112
+ hash: -3608972705387088730
112
113
  requirements: []
113
114
  rubyforge_project:
114
115
  rubygems_version: 1.8.23