module AwesomeXML::Type
Constants
- NATIVE_TYPE_CLASSES
Public Class Methods
for(type, class_name)
click to toggle source
Takes a type (Symbol, String or Class) passed in from a ‘.node` method call and the name of the class it was called in. The latter is needed to correctly assign the namespace if the type is given in String form. Returns a class, either one of the native `AwesomeXML` types or a user-defined class. Raises an exception if `type` is given as a Symbol, but does not represent one of the native types.
# File lib/awesome_xml/type.rb, line 21 def self.for(type, class_name) case type when Symbol NATIVE_TYPE_CLASSES[type] || fail(UnknownNodeType.new(type)) when String [class_name, type].join('::').constantize when Class type end end