summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2012-10-14 10:55:45 +0900
committerRandy Morgan <[email protected]>2012-10-14 10:55:45 +0900
commit553e7cf13358afe2a71c32082d5be6dbe939ad72 (patch)
tree3378170d11a00359864620f4a86588c106dcdaba
parent081c3761ec9100c19a4f9c6c8949c35c10aba29b (diff)
downloadcaxlsx-553e7cf13358afe2a71c32082d5be6dbe939ad72.tar.gz
caxlsx-553e7cf13358afe2a71c32082d5be6dbe939ad72.zip
Refactored CellProtection to use options parser and serialized attributes
-rw-r--r--lib/axlsx/stylesheet/cell_protection.rb11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/axlsx/stylesheet/cell_protection.rb b/lib/axlsx/stylesheet/cell_protection.rb
index 4309b0e8..9f8093ae 100644
--- a/lib/axlsx/stylesheet/cell_protection.rb
+++ b/lib/axlsx/stylesheet/cell_protection.rb
@@ -5,6 +5,11 @@ module Axlsx
# @see Styles#add_style
class CellProtection
+ include Axlsx::OptionsParser
+ include Axlsx::SerializedAttributes
+
+ serializable_attributes :hidden, :locked
+
# specifies locking for cells that have the style containing this protection
# @return [Boolean]
attr_reader :hidden
@@ -17,9 +22,7 @@ module Axlsx
# @option options [Boolean] hidden value for hidden protection
# @option options [Boolean] locked value for locked protection
def initialize(options={})
- options.each do |o|
- self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
- end
+ parse_options options
end
# @see hidden
@@ -32,7 +35,7 @@ module Axlsx
# @return [String]
def to_xml_string(str = '')
str << '<protection '
- str << instance_values.map { |key, value| '' << key.to_s << '="' << value.to_s << '"' }.join(' ')
+ serialized_attributes str
str << '/>'
end