From 553e7cf13358afe2a71c32082d5be6dbe939ad72 Mon Sep 17 00:00:00 2001 From: Randy Morgan Date: Sun, 14 Oct 2012 10:55:45 +0900 Subject: Refactored CellProtection to use options parser and serialized attributes --- lib/axlsx/stylesheet/cell_protection.rb | 11 +++++++---- 1 file 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 << '' end -- cgit v1.2.3