Permalink
Browse files

callbackwrapper, rearranging test files

  • Loading branch information...
1 parent f5b13c7 commit af4a3fb0bda8fe1381600f1ea9afd562db1641d1 andrea@VEGETA committed Mar 24, 2010
@@ -0,0 +1,20 @@
+
+class CallbackWrapper
+
+ def initialize(method)
+ @method = method
+ end
+
+
+ def matches_widget?(widget)
+ method_target_and_event = @method.name.sub("on_", "")
+ return method_target_and_event.scan(/^#{widget.name}/).any?
+ end
+
+ def event_name(widget)
+ event_name = @method.name.split(widget.name)[1]
+ return event_name.sub("_", "").gsub("_", "-")
+ end
+
+
+end
@@ -13,6 +13,12 @@ def widgets
return @widgets.select { |widget| widget.kind_of? BindingBase }
end
+ def get_all_callbacks
+ return self.methods.select do |method_name|
+ method =~ /^on_/i
+ end.map { |method_name| CallbackWrapper.new(method(method_name)) }
+ end
+
def self.container_options
return {:model => :prototype}
end

0 comments on commit af4a3fb

Please sign in to comment.