Method: Hanami.setup

Defined in:
lib/hanami.rb

.setup(raise_exception: true) ⇒ app

Finds and loads the Hanami app file (config/app.rb).

Raises an exception if the app file cannot be found.

Returns:

  • the loaded app class

Since:

  • 2.0.0

API:

  • public



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/hanami.rb', line 51

def self.setup(raise_exception: true)
  return app if app?

  app_path = self.app_path

  if app_path
    prepare_load_path
    require(app_path.to_s)
    app
  elsif raise_exception
    raise(
      AppLoadError,
      "Could not locate your Hanami app file.\n\n" \
      "Your app file should be at `config/app.rb` in your project's root directory."
    )
  end
end