class WsdlMapper::Naming::NamerBase
This is the base class of all namers, which implements common functionality.
A namer is responsible for generating ruby class / module / attribute / constant names from schema information.
For the most part, derivations such as {DefaultNamer} just implement common ruby conventions. The interface, though, also allows for complete customization.
Constants
- KEYWORDS
Attributes
module_path[R]
Public Class Methods
new(module_path: [])
click to toggle source
# File lib/wsdl_mapper/naming/namer_base.rb, line 61 def initialize(module_path: []) @module_path = module_path end
Protected Instance Methods
get_accessor_name(name)
click to toggle source
# File lib/wsdl_mapper/naming/namer_base.rb, line 83 def get_accessor_name(name) get_key_name name end
get_constant_name(name)
click to toggle source
# File lib/wsdl_mapper/naming/namer_base.rb, line 75 def get_constant_name(name) get_key_name(name).upcase end
get_file_name(name)
click to toggle source
# File lib/wsdl_mapper/naming/namer_base.rb, line 91 def get_file_name(name) underscore(name) + '.rb' end
get_file_path(path)
click to toggle source
# File lib/wsdl_mapper/naming/namer_base.rb, line 95 def get_file_path(path) path.map do |m| underscore m end end
get_key_name(name)
click to toggle source
# File lib/wsdl_mapper/naming/namer_base.rb, line 79 def get_key_name(name) underscore sanitize name end
get_var_name(name)
click to toggle source
# File lib/wsdl_mapper/naming/namer_base.rb, line 87 def get_var_name(name) "@#{get_accessor_name(name)}" end
make_parents(path)
click to toggle source
# File lib/wsdl_mapper/naming/namer_base.rb, line 66 def make_parents(path) return if path.empty? mod, path = path.last, path[0...-1] type_name = TypeName.new mod, path, get_file_name(mod), get_file_path(path) type_name.parent = make_parents path type_name end
sanitize(name)
click to toggle source
# File lib/wsdl_mapper/naming/namer_base.rb, line 101 def sanitize(name) if valid_symbol? name name else "x_#{name}" end end
valid_symbol?(name)
click to toggle source
# File lib/wsdl_mapper/naming/namer_base.rb, line 109 def valid_symbol?(name) name =~ /^[a-zA-Z]/ && !KEYWORDS.include?(name.to_s) end