class ActionHandler::Object

Public Class Methods

const_missing(name) click to toggle source

Perhaps this warning is a RuboCop's bug. rubocop:disable Lint/NestedMethodDefinition

Calls superclass method
# File lib/action_handler.rb, line 30
def Object.const_missing(name)
  # rubocop:enable Lint/NestedMethodDefinition

  return super unless name =~ /\A[a-zA-Z0-9_]+Handler\z/
  return super if name == :ActionHandler

  # Try to autoload the corresponding controller.
  prefix = name.to_s.sub(/Handler\z/, '')
  begin
    const_get("::#{prefix}Controller")
  rescue NameError
    super
  end

  # Return the handler if loaded.
  return const_get(name) if Object.const_defined?(name)

  # Otherwise raise the NameError.
  super
end