Module: RuGUI::SignalSupport

Included in:
BaseController, BaseView
Defined in:
lib/rugui/signal_support.rb

Defined Under Namespace

Modules: ClassMethods Classes: SignalConnection

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



43
44
45
46
47
# File 'lib/rugui/signal_support.rb', line 43

def self.included(base)
  base.class_inheritable_accessor :signal_connections
  base.signal_connections = []
  base.extend(ClassMethods)
end

Instance Method Details

#autoconnect_declared_signals(sender) ⇒ Object

Autoconnects declared signal handlers for the widgets in the sender to methods in this instance, or to blocks which have this instance as context.



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/rugui/signal_support.rb', line 29

def autoconnect_declared_signals(sender)
  self.signal_connections.each do |signal_connection|
    if sender.respond_to?(signal_connection.widget_name)
      widget = sender.send(signal_connection.widget_name)

      if (not signal_connection.receiver_block.nil?) and self.is_a?(signal_connection.receiver_class)
        sender.framework_adapter.connect_declared_signal_block(widget, signal_connection.signal_name, self, signal_connection.receiver_block)
      elsif not signal_connection.receiver_method_name.nil? and self.respond_to?(signal_connection.receiver_method_name)
        sender.framework_adapter.connect_declared_signal(widget, signal_connection.signal_name, self, signal_connection.receiver_method_name)
      end
    end
  end
end