Class: Eventifier::Notifier
- Inherits:
-
Object
- Object
- Eventifier::Notifier
- Defined in:
- lib/eventifier/notifier/notifier.rb
Constant Summary collapse
- OPTION_KEYS =
[:email, :if, :unless, :notify_self]
Instance Method Summary collapse
-
#initialize(klasses, *arguments) ⇒ Notifier
constructor
arguments will either be [:relation, => :create] or [=> :second_relation, :on => :create] If it’s the first one, relation is the first in the array, otherwise treat the whole thing like a hash.
Constructor Details
#initialize(klasses, *arguments) ⇒ Notifier
arguments will either be [:relation, => :create] or
- => :second_relation, :on => :create
-
If it’s the first one, relation is the first in the array, otherwise treat the whole thing like a hash
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/eventifier/notifier/notifier.rb', line 7 def initialize(klasses, *arguments) relation = arguments.shift if arguments.length >= 2 arguments = arguments.first || {} methods = Array arguments.delete(:on) = arguments.slice *OPTION_KEYS relation ||= arguments.except *OPTION_KEYS klasses.each do |target_klass| methods.each do |method_name| Eventifier::NotificationMapping.add "#{method_name}.#{target_klass.name.tableize}", relation Eventifier::NotificationSubscriber.subscribe_to_method target_klass, method_name, end end end |