Modified: MacRuby/trunk/lib/hotcocoa/mapper.rb (815 => 816)
--- MacRuby/trunk/lib/hotcocoa/mapper.rb 2009-02-27 12:44:55 UTC (rev 815)
+++ MacRuby/trunk/lib/hotcocoa/mapper.rb 2009-02-27 12:54:37 UTC (rev 816)
@@ -49,7 +49,7 @@
Views[guid] = control if guid
inst.customize(control)
map.each do |key, value|
- if control.respond_to?(key) && value == true
+ if control.respond_to?(key) and not control.respond_to?("#{key}=") and value == true
if control.respond_to?("set#{key.to_s.capitalize}")
eval "control.set#{key.to_s.capitalize}(true)"
else
@@ -71,6 +71,10 @@
end
control
end
+ # make the function callable using HotCocoa.xxxx
+ HotCocoa.send(:module_function, builder_method)
+ # module_function makes the instance method private, but we want it to stay public
+ HotCocoa.send(:public, builder_method)
self
end
Modified: MacRuby/trunk/test-macruby/cases/hotcocoa/mappings_test.rb (815 => 816)
--- MacRuby/trunk/test-macruby/cases/hotcocoa/mappings_test.rb 2009-02-27 12:44:55 UTC (rev 815)
+++ MacRuby/trunk/test-macruby/cases/hotcocoa/mappings_test.rb 2009-02-27 12:54:37 UTC (rev 816)
@@ -31,6 +31,12 @@
assert Mappings.frameworks.is_a?(Hash)
end
+ it "should create a mapping to a class with a module and instance method" do
+ Mappings.map(:method_name_that_does_not_already_exist => SampleClass) {}
+ assert_respond_to HotCocoa, :method_name_that_does_not_already_exist
+ assert_respond_to HotCocoa.new, :method_name_that_does_not_already_exist
+ end
+
it "should create a mapping to a class with a Class instance given to #map" do
Mappings.map(:klass => SampleClass) {}
assert_equal SampleClass, Mappings.mappings[:klass].control_class