summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2013-08-17 13:51:07 +0900
committerRandy Morgan <[email protected]>2013-08-17 13:51:07 +0900
commit3411a6d22a228e7170e4058d1d1715ef507ccffb (patch)
tree4058701aa58846a708698c33eff3df8bc093b11d /lib
parentb88f9d8fdcb644b7c5632987120fda346679a16f (diff)
downloadcaxlsx-3411a6d22a228e7170e4058d1d1715ef507ccffb.tar.gz
caxlsx-3411a6d22a228e7170e4058d1d1715ef507ccffb.zip
safe to camel all values
Diffstat (limited to 'lib')
-rw-r--r--lib/axlsx/util/serialized_attributes.rb17
1 files 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