class String # reloads controller classes on each request if # :allow_reloading is set to true in the config # file or command line options. def import if Merb::Server.allow_reloading Object.send(:remove_const, self.camel_case.intern) rescue nil load(self.snake_case + '.rb') else require(self.snake_case) end end # "FooBar".snake_case #=> "foo_bar" def snake_case gsub(/\B[A-Z]/, '_\&').downcase end # "foo_bar".camel_case #=> "FooBar" def camel_case split('_').map{|e| e.capitalize}.join end # Concatenates a path def /(o) File.join(self, o.to_s) end end