Module: Axlsx::SerializedAttributes
- Included in:
- Border, CellAlignment, CellProtection, CellStyle, Cfvo, Col, Color, ConditionalFormattingRule, DataBar, DefinedName, FilterColumn, Filters, Filters::DateGroupItem, GradientFill, Hyperlink, IconSet, NumFmt, PageMargins, PageSetUpPr, PageSetup, Pane, PictureLocking, PrintOptions, ProtectedRange, Selection, SheetCalcPr, SheetPr, SheetProtection, SheetView, TableStyle, TableStyleElement, TableStyleInfo, TableStyles, WorksheetHyperlink, Xf
- Defined in:
- lib/axlsx/util/serialized_attributes.rb
Overview
This module allows us to define a list of symbols defining which attributes will be serialized for a class.
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.included(base) ⇒ Object
Extend with class methods.
Instance Method Summary collapse
-
#serialized_attributes(str = '', additional_attributes = {}) ⇒ Object
serializes the instance values of the defining object based on the list of serializable attributes.
Class Method Details
.included(base) ⇒ Object
Extend with class methods
7 8 9 |
# File 'lib/axlsx/util/serialized_attributes.rb', line 7 def self.included(base) base.send :extend, ClassMethods end |
Instance Method Details
#serialized_attributes(str = '', additional_attributes = {}) ⇒ Object
serializes the instance values of the defining object based on the list of serializable attributes. serialization to. defining values that are not serializable attributes list.
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/axlsx/util/serialized_attributes.rb', line 32 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| str << "#{Axlsx.camel(key, false)}=\"#{value}\" " end str end |