Class: Disclosure::Rule
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Disclosure::Rule
- Defined in:
- app/models/disclosure/rule.rb
Instance Method Summary collapse
-
#notifier ⇒ Object
Public: Find the notifier class instance from the class name (string) that is saved in the model table.
-
#react!(model) ⇒ Object
Public: Tell the reactor for this rule that it should now react to a change.
-
#reactor ⇒ Object
Public: Find the reactor class instance from the class name (string) that is saved in the model table.
Instance Method Details
#notifier ⇒ Object
Public: Find the notifier class instance from the class name (string) that is saved in the model table.
Returns the notifier class or nil
21 22 23 24 25 26 27 28 |
# File 'app/models/disclosure/rule.rb', line 21 def notifier begin self.notifier_class.constantize rescue NameError => exp Rails.logger.info "Disclosure could not find notifier: #{exp.}" return nil end end |
#react!(model) ⇒ Object
Public: Tell the reactor for this rule that it should now react to a change.
Passes along the instance of the model that changed, the action that occurred, and the owner of the rule
model - The model instance that changed
Returns truthy value if the reactor returned successfully, and false if not. Depending on the reactor, may raise exceptions - for example, Net::SMTP errors if sending email.
51 52 53 |
# File 'app/models/disclosure/rule.rb', line 51 def react!(model) reactor.react!(model, action, owner) end |
#reactor ⇒ Object
Public: Find the reactor class instance from the class name (string) that is saved in the model table.
Returns the reactor class or nil
35 36 37 38 39 |
# File 'app/models/disclosure/rule.rb', line 35 def reactor Disclosure.configuration.reactor_classes.select do |rc| rc.name == self.reactor_class end.first end |