Module: XML::Mapping::ClassMethods
- Defined in:
- lib/default_root_element_name.rb
Instance Method Summary collapse
-
#default_root_element_name ⇒ Object
The default root element name for this class.
Instance Method Details
#default_root_element_name ⇒ Object
The default root element name for this class. Equals the class name, with all parent module names stripped, and with capital letters converted to lowercase and preceded by a dash; e.g. “Foo::Bar::MySampleClass” becomes “my-sample-class”.
11 12 13 |
# File 'lib/default_root_element_name.rb', line 11 def default_root_element_name self.name.split('::')[-1].gsub(/^(.)/){$1.downcase}.gsub(/(.)([A-Z])/){$1+"_"+$2.downcase} end |