Class: SAXMachine::SAXConfig::AttributeConfig
- Inherits:
-
Object
- Object
- SAXMachine::SAXConfig::AttributeConfig
- Defined in:
- lib/sax-machine/sax_attribute_config.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#setter ⇒ Object
readonly
Returns the value of attribute setter.
Instance Method Summary collapse
- #attrs_match?(attrs) ⇒ Boolean
- #collection? ⇒ Boolean
- #column ⇒ Object
- #has_value_and_attrs_match?(attrs) ⇒ Boolean
-
#initialize(name, options) ⇒ AttributeConfig
constructor
A new instance of AttributeConfig.
- #required? ⇒ Boolean
- #value_from_attrs(attrs) ⇒ Object
Constructor Details
#initialize(name, options) ⇒ AttributeConfig
Returns a new instance of AttributeConfig.
7 8 9 10 11 12 |
# File 'lib/sax-machine/sax_attribute_config.rb', line 7 def initialize(name, ) @name = name.to_s @as = [:as] @setter = "#{@as}=" @required = [:required] end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/sax-machine/sax_attribute_config.rb', line 5 def name @name end |
#setter ⇒ Object (readonly)
Returns the value of attribute setter.
5 6 7 |
# File 'lib/sax-machine/sax_attribute_config.rb', line 5 def setter @setter end |
Instance Method Details
#attrs_match?(attrs) ⇒ Boolean
26 27 28 |
# File 'lib/sax-machine/sax_attribute_config.rb', line 26 def attrs_match?(attrs) attrs.index(@name) ? true : false end |
#collection? ⇒ Boolean
34 35 36 |
# File 'lib/sax-machine/sax_attribute_config.rb', line 34 def collection? false end |
#column ⇒ Object
14 15 16 |
# File 'lib/sax-machine/sax_attribute_config.rb', line 14 def column @as || @name.to_sym end |
#has_value_and_attrs_match?(attrs) ⇒ Boolean
30 31 32 |
# File 'lib/sax-machine/sax_attribute_config.rb', line 30 def has_value_and_attrs_match?(attrs) attrs_match?(attrs) end |
#required? ⇒ Boolean
18 19 20 |
# File 'lib/sax-machine/sax_attribute_config.rb', line 18 def required? @required end |
#value_from_attrs(attrs) ⇒ Object
22 23 24 |
# File 'lib/sax-machine/sax_attribute_config.rb', line 22 def value_from_attrs(attrs) attrs.index(@name) ? attrs[attrs.index(@name) + 1] : nil end |