Module: Axlsx::Accessors::ClassMethods
- Defined in:
- lib/axlsx/util/accessors.rb
Overview
Defines the class level xxx_attr_accessor methods
Constant Summary collapse
- SETTER =
Template for defining validated write accessors
"def %s=(value) Axlsx::%s(value); @%s = value; end"
Instance Method Summary collapse
-
#boolean_attr_accessor(*symbols) ⇒ Object
Creates on or more boolean validated attr_accessors names of the attributes you will add to your class.
-
#string_attr_accessor(*symbols) ⇒ Object
Creates one or more string validated attr_accessors names of the attributes you will add to your class.
-
#validated_attr_accessor(symbols, validator) ⇒ Object
Creates the reader and writer access methods validating assignation.
Instance Method Details
#boolean_attr_accessor(*symbols) ⇒ Object
Creates on or more boolean validated attr_accessors names of the attributes you will add to your class.
28 29 30 |
# File 'lib/axlsx/util/accessors.rb', line 28 def boolean_attr_accessor(*symbols) validated_attr_accessor(symbols, 'validate_boolean') end |
#string_attr_accessor(*symbols) ⇒ Object
Creates one or more string validated attr_accessors names of the attributes you will add to your class.
21 22 23 |
# File 'lib/axlsx/util/accessors.rb', line 21 def string_attr_accessor(*symbols) validated_attr_accessor(symbols, 'validate_string') end |
#validated_attr_accessor(symbols, validator) ⇒ Object
Creates the reader and writer access methods validating assignation.
40 41 42 43 44 45 |
# File 'lib/axlsx/util/accessors.rb', line 40 def validated_attr_accessor(symbols, validator) symbols.each do |symbol| attr_reader symbol module_eval(SETTER % [symbol.to_s, validator, symbol.to_s], __FILE__, __LINE__) end end |