disclosure 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,9 +2,7 @@ module Disclosure
2
2
  class Rule < ActiveRecord::Base
3
3
  belongs_to :owner, :class_name => Disclosure.configuration.owner_class
4
4
 
5
- validates :notifier_class, :inclusion => {
6
- :in => proc { Disclosure.configuration.notifier_classes.map(&:name) }
7
- }
5
+ validates :notifier_class, :presence => true
8
6
 
9
7
  validates :reactor_class, :inclusion => {
10
8
  :in => proc { Disclosure.configuration.reactor_classes.map(&:name) }
@@ -21,11 +19,15 @@ module Disclosure
21
19
  #
22
20
  # Returns the notifier class or nil
23
21
  def notifier
24
- Disclosure.configuration.notifier_classes.select do |nc|
25
- nc.name == self.notifier_class
26
- end.first
22
+ begin
23
+ self.notifier_class.constantize
24
+ rescue NameError => exp
25
+ Rails.logger.info "Disclosure could not find notifier: #{exp.message}"
26
+ return nil
27
+ end
27
28
  end
28
29
 
30
+
29
31
  # Public: Find the reactor class instance from the
30
32
  # class name (string) that is saved in the model table.
31
33
  #
@@ -1,3 +1,3 @@
1
1
  module Disclosure
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
data/lib/disclosure.rb CHANGED
@@ -38,13 +38,12 @@ module Disclosure
38
38
  end
39
39
 
40
40
  def self.react_to!(model)
41
- unless Disclosure.configuration.notifier_classes.include?(model.class)
42
- return nil
43
- end
41
+ user_id_method = "#{Disclosure.configuration.owner_class.underscore}_id"
42
+ return nil unless model.respond_to?(user_id_method)
44
43
 
45
44
  Disclosure::Rule.where(
46
45
  :notifier_class => model.class.name,
47
- :owner_id => model.send("#{Disclosure.configuration.owner_class.underscore}_id")
46
+ :owner_id => model.send(user_id_method)
48
47
  ).each do |rule|
49
48
  next if !model.send("#{rule.action}?")
50
49
  rule.react!(model)
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.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-02 00:00:00.000000000 Z
12
+ date: 2013-04-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -100,7 +100,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
100
100
  version: '0'
101
101
  segments:
102
102
  - 0
103
- hash: 4604734519384497078
103
+ hash: -2030519306870457110
104
104
  required_rubygems_version: !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
109
  version: '0'
110
110
  segments:
111
111
  - 0
112
- hash: 4604734519384497078
112
+ hash: -2030519306870457110
113
113
  requirements: []
114
114
  rubyforge_project:
115
115
  rubygems_version: 1.8.23