Commit 81f1e9d

mo khan <mo@mokhan.ca>
2015-04-08 19:12:06
dynamically pass parameters to xml node based on whether there is text content or not.
1 parent 55a6d4b
Changed files (1)
lib
scale
lib/scale/node.rb
@@ -28,17 +28,9 @@ module Scale
     end
 
     def append_to(builder)
-      if content.nil?
-        builder.send(xml_tag.to_sym, xml_attributes) do
-          each do |node|
-            node.append_to(builder)
-          end
-        end
-      else
-        builder.send(xml_tag.to_sym, content, xml_attributes) do
-          each do |node|
-            node.append_to(builder)
-          end
+      builder.send(xml_tag.to_sym, *xml_parameters) do
+        each do |node|
+          node.append_to(builder)
         end
       end
     end
@@ -46,5 +38,12 @@ module Scale
     def xml_attributes
       attributes.delete_if { |key, value| value.nil? }
     end
+
+    private
+
+    def xml_parameters
+      return [xml_attributes] if content.nil?
+      [content, xml_attributes]
+    end
   end
 end