assets/src/ruboto/widget.rb in ruboto-0.16.0 vs assets/src/ruboto/widget.rb in ruboto-1.0.0

- old
+ new

@@ -45,29 +45,39 @@ end def configure(context, params = {}) if width = params.delete(:width) getLayoutParams.width = View.convert_constant(width) + puts "\nDEPRECATION: The ':width' option is deprecated. Use :layout => {:width => XX} instead." end if height = params.delete(:height) getLayoutParams.height = View.convert_constant(height) + puts "\nDEPRECATION: The ':height' option is deprecated. Use :height => {:width => XX} instead." end if margins = params.delete(:margins) getLayoutParams.set_margins(*margins) + puts "\nDEPRECATION: The ':margins' option is deprecated. Use :layout => {:margins => XX} instead." end if layout = params.delete(:layout) lp = getLayoutParams layout.each do |k, v| - method_name = k.to_s.gsub(/_([a-z])/) { $1.upcase } + method_name = k.to_s + if lp.respond_to?("#{k}=") + method_name = "#{k}=" + elsif method_name.include?("_") + method_name = method_name.gsub(/_([a-z])/){$1.upcase} + method_name = "#{method_name}=" if lp.respond_to?("#{method_name}=") + end + invoke_with_converted_arguments(lp, method_name, v) end end params.each do |k, v| - method_name = "set#{k.to_s.gsub(/(^|_)([a-z])/) { $2.upcase }}" + method_name = self.respond_to?("#{k}=") ? "#{k}=" : k invoke_with_converted_arguments(self, method_name, v) end end end