From 3411a6d22a228e7170e4058d1d1715ef507ccffb Mon Sep 17 00:00:00 2001 From: Randy Morgan Date: Sat, 17 Aug 2013 13:51:07 +0900 Subject: safe to camel all values --- lib/axlsx/util/serialized_attributes.rb | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/axlsx/util/serialized_attributes.rb b/lib/axlsx/util/serialized_attributes.rb index 80ac3c46..76ec7e41 100644 --- a/lib/axlsx/util/serialized_attributes.rb +++ b/lib/axlsx/util/serialized_attributes.rb @@ -40,18 +40,21 @@ module Axlsx # @param [Hash] additional_attributes An option key value hash for # defining values that are not serializable attributes list. def serialized_attributes(str = '', additional_attributes = {}) - key_value_pairs = instance_values - key_value_pairs.each do |key, value| - key_value_pairs.delete(key) if value == nil - key_value_pairs.delete(key) unless self.class.xml_attributes.include?(key.to_sym) - end - key_value_pairs.merge! additional_attributes - key_value_pairs.each do |key, value| + attributes = declared_attributes.merge! additional_attributes + attributes.each do |key, value| str << "#{Axlsx.camel(key, false)}=\"#{Axlsx.camel(value, false)}\" " end str end + def declared_attributes + declared = instance_values + declared.each do |key, value| + declared.delete(key) if value == nil || !self.class.xml_attributes.include?(key.to_sym) + end + declared + end + # serialized instance values at text nodes on a camelized element of the # attribute name. You may pass in a block for evaluation against non nil # values. We use an array for element attributes becuase misordering will -- cgit v1.2.3