Permalink
Browse files

forwarding alpha

  • Loading branch information...
1 parent d1392f4 commit ee790f0362873c2a0d2f91cda34f4bb49a14d51c andrea@VEGETA committed Mar 26, 2010
Showing with 17 additions and 7 deletions.
  1. +15 −6 lib/freightrain/signals/signal_host.rb
  2. +2 −1 lib/freightrain/views/freight_view.rb
@@ -18,13 +18,22 @@ def signals
def create_signals
@signals = {}
- signal_keys = self.class.instance_variable_get(:@signals)
- signal_keys ||= []
- signal_keys.each do |signal|
+ signals = self.class.instance_variable_get(:@signals)
+ signals ||= {}
+ signals.keys.each do |signal|
+ create_forward_method(signals[signal], signal) if signals[signal]
@signals[signal] = FreightSignal.new
end
end
+ def create_forward_method(target_description, signal)
+ target = target_description[:forwards].split(".")[0]
+ event = target_description[:forwards].split(".")[1]
+ self.class.send(:define_method, "#{target}_on_#{event}") do
+ fire signal.to_sym
+ end
+ end
+
def hook_to_signals(host, prefix = nil)
@signals.each do |signal_key, signal|
method_name = "on_#{signal_key}"
@@ -37,9 +46,9 @@ def hook_to_signals(host, prefix = nil)
end
end
- def signal(signal_name)
- @signals ||= []
- @signals << signal_name.to_sym
+ def signal(signal_name, options = nil)
+ @signals ||= {}
+ @signals[signal_name.to_sym] = options
end
end
@@ -32,6 +32,7 @@ def toplevel
end
def initialize()
+ create_signals
@widgets = []
if(Freightrain.toolkit)
self.class.instance_eval("include Toolkit::DialogHelper")
@@ -40,7 +41,7 @@ def initialize()
end
hook_to_layout_widgets()
load_bindings_from_file(@widgets)
- create_signals
+
end
def hook_to_layout_widgets

0 comments on commit ee790f0

Please sign in to comment.