Method: Rodbot::Refinements#constantize

Defined in:
lib/rodbot/refinements.rb

#constantizeClass, Module

Convert module or class path to module or class

Examples:

'foo/bar_baz'.constantize   # => Foo::BarBaz

Returns:

  • (Class, Module)

    class or module



29
30
31
32
33
# File 'lib/rodbot/refinements.rb', line 29

refine String do
  def constantize
    Module.const_get(self.split('/').map(&:camelize).join('::'))
  end
end