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, o = {}) ⇒ 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, o = {}) ⇒ Attribute
Additional options:
:default => Object The default value for this
8 9 10 11 |
# File 'lib/happymapper/attribute.rb', line 8 def initialize(name, type, o={}) super self.default = o[:default] end |
Instance Attribute Details
#default ⇒ Object
Returns the value of attribute default.
3 4 5 |
# File 'lib/happymapper/attribute.rb', line 3 def default @default end |
Instance Method Details
#find(node, namespace, xpath_options) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/happymapper/attribute.rb', line 13 def find(node, namespace, ) if [:xpath] yield(node.xpath([:xpath],)) else yield(node[tag]) end end |