summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/util/serialized_attributes.rb
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2012-10-14 08:45:50 +0900
committerRandy Morgan <[email protected]>2012-10-14 08:45:50 +0900
commitef503bd236e5130d92c7c5f057a839aa17064555 (patch)
treef71f1a11ff55f7ba3edbc133abec7f8b133e7a2b /lib/axlsx/util/serialized_attributes.rb
parent4612f09d5ab8233d4a3f6781976aa26c2d503d01 (diff)
downloadcaxlsx-ef503bd236e5130d92c7c5f057a839aa17064555.tar.gz
caxlsx-ef503bd236e5130d92c7c5f057a839aa17064555.zip
Corrected serializable_attributes declaraion and added an additional_attributes parameter to specify attributes that are not instance_values
Diffstat (limited to 'lib/axlsx/util/serialized_attributes.rb')
-rw-r--r--lib/axlsx/util/serialized_attributes.rb15
1 files 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