Class: RubyMVC::Toolkit::NotificationRelay

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_mvc/toolkit/notification.rb

Overview

This class is used to relay notifications from one sender to another sender’s registered listeners.

Instance Method Summary collapse

Constructor Details

#initialize(sender, listeners) ⇒ NotificationRelay

Returns a new instance of NotificationRelay.



88
89
90
91
# File 'lib/ruby_mvc/toolkit/notification.rb', line 88

def initialize(sender, listeners)
  @listeners = listeners
  @sender = sender
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



93
94
95
96
# File 'lib/ruby_mvc/toolkit/notification.rb', line 93

def method_missing(method, *args, &block)
  args[0] = @sender
  @listeners.each { |l| l.send(method, *args, &block) }
end