# File lib/puppet/indirector/terminus.rb, line 45
45:     def inherited(subclass)
46:       longname = subclass.to_s
47:       if longname =~ /#<Class/
48:         raise Puppet::DevError, "Terminus subclasses must have associated constants"
49:       end
50:       names = longname.split("::")
51: 
52:       # Convert everything to a lower-case symbol, converting camelcase to underscore word separation.
53:       name = names.pop.sub(/^[A-Z]/) { |i| i.downcase }.gsub(/[A-Z]/) { |i| "_#{i.downcase}" }.intern
54: 
55:       subclass.name = name
56: 
57:       # Short-circuit the abstract types, which are those that directly subclass
58:       # the Terminus class.
59:       if self == Puppet::Indirector::Terminus
60:         subclass.mark_as_abstract_terminus
61:         return
62:       end
63: 
64:       # Set the terminus type to be the name of the abstract terminus type.
65:       # Yay, class/instance confusion.
66:       subclass.terminus_type = self.name
67: 
68:       # Our subclass is specifically associated with an indirection.
69:       raise("Invalid name #{longname}") unless names.length > 0
70:       indirection_name = names.pop.sub(/^[A-Z]/) { |i| i.downcase }.gsub(/[A-Z]/) { |i| "_#{i.downcase}" }.intern
71: 
72:       if indirection_name == "" or indirection_name.nil?
73:         raise Puppet::DevError, "Could not discern indirection model from class constant"
74:       end
75: 
76:       # This will throw an exception if the indirection instance cannot be found.
77:       # Do this last, because it also registers the terminus type with the indirection,
78:       # which needs the above information.
79:       subclass.indirection = indirection_name
80: 
81:       # And add this instance to the instance hash.
82:       Puppet::Indirector::Terminus.register_terminus_class(subclass)
83:     end