Sha256: e25cc9d27fc02a8f1337e185c299212d761ed22123b32d81bbe0f23f9383e722

Contents?: true

Size: 579 Bytes

Versions: 4

Compression:

Stored size: 579 Bytes

Contents

module ClassFinder

  # Name is an underscore name string or symbol
  def find(name)
    klass = nil
    klass_name = Inflector.camelize(name)

    begin
      klass = Object.const_get(klass_name)
    rescue NameError
      # not there yet
      begin
        require "#{name}"
      rescue LoadError => ex
        # maybe its included somewhere else
      ensure
        begin
          klass = Object.const_get(klass_name)
        rescue
          # leave this alone.. maybe there isnt a NameView
        end
      end
    end
    
    klass
  end
  module_function :find

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gamebox-0.1.1 lib/gamebox/class_finder.rb
gamebox-0.1.0 lib/gamebox/class_finder.rb
gamebox-0.0.9 lib/gamebox/class_finder.rb
gamebox-0.0.8 lib/gamebox/class_finder.rb