Class: Bogus::ConvertsNameToClass

Inherits:
Object
  • Object
show all
Extended by:
Takes
Defined in:
lib/bogus/fakes/converts_name_to_class.rb

Defined Under Namespace

Classes: CanNotFindClass

Instance Method Summary collapse

Methods included from Takes

takes

Instance Method Details

#convert(name) ⇒ Object

Raises:



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/bogus/fakes/converts_name_to_class.rb', line 9

def convert(name)
  class_name = camelize(name)
  klass = nil

  @search_modules.each do |mod|
    klass = mod.const_get(class_name) rescue nil
    break if klass
  end

  raise CanNotFindClass.new("Can not locate class for name: #{name}") unless klass

  klass
end