Class: Ebay::Schema::Node
- Inherits:
-
Object
- Object
- Ebay::Schema::Node
- Includes:
- Inflections
- Defined in:
- lib/ebay/schema/mapper/node.rb
Direct Known Subclasses
ArrayNode, BooleanNode, MoneyNode, NumericNode, ObjectNode, TextNode, ValueArrayNode, ValueNode
Constant Summary
Constants included from Inflections
Inflections::DOWNCASE_TOKENS, Inflections::NAME_MAPPINGS, Inflections::UPCASE_TOKENS
Instance Attribute Summary collapse
-
#max ⇒ Object
Returns the value of attribute max.
-
#min ⇒ Object
Returns the value of attribute min.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #accessor_name ⇒ Object
- #declaration ⇒ Object
-
#initialize(name, attributes = {}) ⇒ Node
constructor
A new instance of Node.
- #optional? ⇒ Boolean
- #xml_mapping_node_type ⇒ Object
Methods included from Inflections
#downcase_first_character, #ebay_camelize, #ebay_underscore, #underscore, #upcase_first_character
Constructor Details
#initialize(name, attributes = {}) ⇒ Node
Returns a new instance of Node.
8 9 10 11 12 13 14 15 |
# File 'lib/ebay/schema/mapper/node.rb', line 8 def initialize(name, attributes = {}) @name = name @type = attributes[:type] @min = attributes[:min] || "1" @max = attributes[:max] || "1" @field = attributes[:field] @child = attributes[:child] end |
Instance Attribute Details
#max ⇒ Object
Returns the value of attribute max.
7 8 9 |
# File 'lib/ebay/schema/mapper/node.rb', line 7 def max @max end |
#min ⇒ Object
Returns the value of attribute min.
7 8 9 |
# File 'lib/ebay/schema/mapper/node.rb', line 7 def min @min end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/ebay/schema/mapper/node.rb', line 7 def name @name end |
Instance Method Details
#accessor_name ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/ebay/schema/mapper/node.rb', line 21 def accessor_name name = ebay_underscore(@name) if name =~ /_array$/ name.gsub!(/_array$/, '') ActiveSupport::Inflector.pluralize(name) else name end end |
#declaration ⇒ Object
35 36 37 |
# File 'lib/ebay/schema/mapper/node.rb', line 35 def declaration "#{xml_mapping_node_type} :#{accessor_name}" end |
#optional? ⇒ Boolean
17 18 19 |
# File 'lib/ebay/schema/mapper/node.rb', line 17 def optional? @min == "0" end |
#xml_mapping_node_type ⇒ Object
31 32 33 |
# File 'lib/ebay/schema/mapper/node.rb', line 31 def xml_mapping_node_type override_type || ActiveSupport::Inflector.demodulize(self.class.to_s).underscore end |