diff options
| author | Randy Morgan <[email protected]> | 2012-11-05 14:08:42 +0900 |
|---|---|---|
| committer | Randy Morgan <[email protected]> | 2012-11-05 14:08:42 +0900 |
| commit | 8ffd7652c4cc66b52f7992f24a2effc7dc3958c8 (patch) | |
| tree | 07e8f9684d241db7fe513c2055ca2789df3361f2 /lib/axlsx/util/serialized_attributes.rb | |
| parent | 75eee58d7aecd0f0e89ec7a8ff2a37e6013f9e8d (diff) | |
| download | caxlsx-8ffd7652c4cc66b52f7992f24a2effc7dc3958c8.tar.gz caxlsx-8ffd7652c4cc66b52f7992f24a2effc7dc3958c8.zip | |
completed documentation
Diffstat (limited to 'lib/axlsx/util/serialized_attributes.rb')
| -rw-r--r-- | lib/axlsx/util/serialized_attributes.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/axlsx/util/serialized_attributes.rb b/lib/axlsx/util/serialized_attributes.rb index 50c8d3ae..bffa0a10 100644 --- a/lib/axlsx/util/serialized_attributes.rb +++ b/lib/axlsx/util/serialized_attributes.rb @@ -1,20 +1,34 @@ module Axlsx + # This module allows us to define a list of symbols defining which + # attributes will be serialized for a class. module SerializedAttributes + # Extend with class methods def self.included(base) base.send :extend, ClassMethods end + # class methods applied to all includers module ClassMethods + # This is the method to be used in inheriting classes to specify + # which of the instance values are serializable def serializable_attributes(*symbols) @xml_attributes = symbols end + + # a reader for those attributes def xml_attributes @xml_attributes end end + # serializes the instance values of the defining object based on the + # list of serializable attributes. + # @param [String] str The string instance to append this + # serialization to. + # @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| |
