Class: Eventifier::NotificationSubscriber

Inherits:
Object
  • Object
show all
Defined in:
lib/eventifier/notifier/notification_subscriber.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass, method_name, options) ⇒ NotificationSubscriber

Returns a new instance of NotificationSubscriber.



6
7
8
# File 'lib/eventifier/notifier/notification_subscriber.rb', line 6

def initialize(klass, method_name, options)
  @klass, @method_name, @options = klass, method_name, options
end

Class Method Details

.subscribe_to_method(klass, method_name, options) ⇒ Object



2
3
4
# File 'lib/eventifier/notifier/notification_subscriber.rb', line 2

def self.subscribe_to_method(klass, method_name, options)
  new(klass, method_name, options).subscribe_to_method
end

Instance Method Details

#subscribe_to_methodObject



10
11
12
13
14
15
16
# File 'lib/eventifier/notifier/notification_subscriber.rb', line 10

def subscribe_to_method
  return if notifications.notifier.listening?(name)

  notifications.subscribe(name) do |*args|
    Eventifier::NotificationTranslator.new(prefix, options, *args).translate
  end
end