Module: Disclosure
- Includes:
- Notifications
- Defined in:
- lib/disclosure.rb,
lib/disclosure/engine.rb,
lib/disclosure/version.rb,
app/models/disclosure/rule.rb,
lib/disclosure/notifications.rb,
app/mailers/disclosure/email_reactor.rb,
app/helpers/disclosure/application_helper.rb,
app/controllers/disclosure/application_controller.rb
Defined Under Namespace
Modules: ApplicationHelper, Notifications
Classes: ActionMethodNotDefined, ApplicationController, Configuration, EmailReactor, Engine, NotifiableActionsNotDefined, Rule
Constant Summary
collapse
- VERSION =
"0.0.8"
Class Attribute Summary collapse
Class Method Summary
collapse
instrument!, subscribe!
Class Attribute Details
.configuration ⇒ Object
Returns the value of attribute configuration.
10
11
12
|
# File 'lib/disclosure.rb', line 10
def configuration
@configuration
end
|
Class Method Details
.bootstrap! ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/disclosure.rb', line 13
def self.bootstrap!
Disclosure.configuration.notifier_classes.each do |klass|
if !klass.methods.include?(:notifiable_actions)
klass.class_eval do
class << self
def notifiable_actions
raise Disclosure::NotifiableActionsNotDefined.new("Notifiable actions must be defined in #{self.name}.")
end
end
end
end
if klass.methods.include?(:notifiable_actions)
(klass.notifiable_actions rescue []).each do |action|
unless klass.instance_methods.include?(:"#{action}?")
klass.send :define_method, :"#{action}?" do
raise Disclosure::ActionMethodNotDefined.new("#{action}? must be defined in #{klass}.")
end
end
end
end
end
end
|
57
58
59
|
# File 'lib/disclosure.rb', line 57
def self.configure
yield(configuration) if block_given?
end
|
.react_to!(model) ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/disclosure.rb', line 40
def self.react_to!(model)
user_id_method = "#{Disclosure.configuration.owner_class.underscore}_id"
return nil unless model.respond_to?(user_id_method)
Disclosure::Rule.where(
:notifier_class => model.class.name,
:owner_id => model.send(user_id_method)
).each do |rule|
next if !model.send("#{rule.action}?")
rule.react!(model)
end
end
|