lib/ronin/auto_load.rb in ronin-1.1.0 vs lib/ronin/auto_load.rb in ronin-1.2.0

- old
+ new

@@ -20,48 +20,50 @@ require 'open_namespace' module Ronin # # When included into other namespaces, it allows for auto-loading Classes - # or Modules via {#const_missing}. + # or Modules via {ClassMethods#const_missing}. # # @since 1.1.0 # module AutoLoad def self.included(base) base.send :include, OpenNamespace - base.send :extend, self + base.send :extend, ClassMethods end - protected + module ClassMethods + protected - # - # Transparently auto-loads Classes and Modules from their respective - # files using [OpenNamespace](http://rubydoc.info/gems/open_namespace). - # - # @param [String, Symbol] name - # The name of the Class or Module to auto-load. - # - # @return [Class, Module] - # The loaded Class or Module. - # - # @raise [NameError] - # The Class or Module could not be found. - # - # @since 1.1.0 - # - # @api public - # - def const_missing(name) - const = super(name) + # + # Transparently auto-loads Classes and Modules from their respective + # files using [OpenNamespace](http://rubydoc.info/gems/open_namespace). + # + # @param [String, Symbol] name + # The name of the Class or Module to auto-load. + # + # @return [Class, Module] + # The loaded Class or Module. + # + # @raise [NameError] + # The Class or Module could not be found. + # + # @since 1.1.0 + # + # @api public + # + def const_missing(name) + const = super(name) - if Object.const_defined?('DataMapper') - # if the loaded Class is a DataMapper Resource, re-finalize - if const < DataMapper::Resource - DataMapper.finalize + if Object.const_defined?('DataMapper') + # if the loaded Class is a DataMapper Resource, re-finalize + if const < DataMapper::Resource + DataMapper.finalize + end end - end - return const + return const + end end end end