class EbayTrading::Schema::Node
Attributes
max[RW]
min[RW]
name[RW]
Public Class Methods
new(name, attributes = {})
click to toggle source
# File lib/ebay_trading/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
Public Instance Methods
accessor_name()
click to toggle source
# File lib/ebay_trading/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()
click to toggle source
# File lib/ebay_trading/schema/mapper/node.rb, line 35 def declaration "#{xml_mapping_node_type} :#{accessor_name}" end
optional?()
click to toggle source
# File lib/ebay_trading/schema/mapper/node.rb, line 17 def optional? @min.to_s == "0" end
xml_mapping_node_type()
click to toggle source
# File lib/ebay_trading/schema/mapper/node.rb, line 31 def xml_mapping_node_type override_type || ActiveSupport::Inflector.demodulize(self.class.to_s).underscore end
Private Instance Methods
clean_class_name(name)
click to toggle source
# File lib/ebay_trading/schema/mapper/node.rb, line 40 def clean_class_name(name) trim_namespace(name.gsub(/Type$/, '')).camelize end
trim_name(type)
click to toggle source
# File lib/ebay_trading/schema/mapper/node.rb, line 44 def trim_name(type) type.gsub(/Type$/,'') end
trim_namespace(name)
click to toggle source
# File lib/ebay_trading/schema/mapper/node.rb, line 48 def trim_namespace(name) name.gsub(/^.*:/,'') end