From ef503bd236e5130d92c7c5f057a839aa17064555 Mon Sep 17 00:00:00 2001 From: Randy Morgan Date: Sun, 14 Oct 2012 08:45:50 +0900 Subject: Corrected serializable_attributes declaraion and added an additional_attributes parameter to specify attributes that are not instance_values --- lib/axlsx/util/serialized_attributes.rb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/axlsx/util/serialized_attributes.rb b/lib/axlsx/util/serialized_attributes.rb index 84a7733e..dd67f75b 100644 --- a/lib/axlsx/util/serialized_attributes.rb +++ b/lib/axlsx/util/serialized_attributes.rb @@ -6,16 +6,21 @@ module Axlsx end module ClassMethods + def serializable_attributes(*symbols) - @@serializable_attributes = symbols + @xml_attributes = symbols + end + def xml_attributes + @xml_attributes end end - def serialized_attributes(str = '') - serializable_values = instance_values.select do |key, value| - self.class.serializable_attributes.include?(key.to_sym) + def serialized_attributes(str = '', additional_attributes = {}) + key_value_pairs = instance_values.select do |key, value| + self.class.xml_attributes.include?(key.to_sym) end - serializable_values.each do |key, value| + key_value_pairs.merge! additional_attributes + key_value_pairs.each do |key, value| str << "#{Axlsx.camel(key, false)}='#{value}' " end str -- cgit v1.2.3