Class: HappyMapper::Attribute
Instance Attribute Summary collapse
-
#default ⇒ Object
Returns the value of attribute default.
Attributes inherited from Item
#name, #namespace, #options, #tag, #type
Instance Method Summary collapse
- #find(node, _namespace, xpath_options) ⇒ Object
-
#initialize(name, type, options = {}) ⇒ Attribute
constructor
Additional options: :default => Object The default value for this.
Methods inherited from Item
#constant, #from_xml_node, #method_name, #typecast, #xpath
Constructor Details
#initialize(name, type, options = {}) ⇒ Attribute
Additional options:
:default => Object The default value for this
10 11 12 13 |
# File 'lib/happymapper/attribute.rb', line 10 def initialize(name, type, = {}) super self.default = [:default] end |
Instance Attribute Details
#default ⇒ Object
Returns the value of attribute default.
5 6 7 |
# File 'lib/happymapper/attribute.rb', line 5 def default @default end |
Instance Method Details
#find(node, _namespace, xpath_options) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/happymapper/attribute.rb', line 15 def find(node, _namespace, ) if [:xpath] yield(node.xpath([:xpath], )) else yield(node.attributes[tag]) end end |