Module: Padrino::Loader

Included in:
Padrino

Instance Method Summary

Instance Method Details

#after_load { ... } ⇒ Array<Proc>

Hooks to be called after a load/reload.

Examples:

after_load do
  DataMapper.finalize
end

Yields:

  • The given block will be called after Padrino was loaded/reloaded.

Returns:

  • (Array<Proc>) — The load/reload hooks.

#before_load { ... } ⇒ Array<Proc>

Hooks to be called before a load/reload.

Examples:

before_load do
  pre_initialize_something
end

Yields:

  • The given block will be called before Padrino was loaded/reloaded.

Returns:

  • (Array<Proc>) — The load/reload before hooks.

#called_from ⇒ Object

This adds the ability to instantiate Padrino.load! after Application definition.

#clear! ⇒ NilClass

Clear the padrino env.

Returns:

  • (NilClass)

#dependency_paths ⇒ Array<String>

Returns default list of path globs to load as dependencies. Appends custom dependency patterns to the be loaded for Padrino.

Examples:

Padrino.dependency_paths << "#{Padrino.root}/uploaders/*.rb"

Returns:

  • (Array<String>) — The dependencey paths.

#load! ⇒ Boolean

Requires necessary dependencies as well as application files from root lib and models.

Returns:

  • (Boolean) — returns true if Padrino is not already bootstraped otherwise else.

#loaded? ⇒ Boolean

Determines whether Padrino was loaded with Padrino.load!.

Returns:

  • (Boolean) — Specifies whether Padrino was loaded.

#precompile_all_routes! ⇒ Object

Precompiles all routes if :precompile_routes is set to true

#reload! ⇒ Object

Method for reloading required applications and their files.

#require_dependencies(*paths) ⇒ Object

Attempts to require all dependency libs that we need. If you use this method we can perform correctly a Padrino.reload! Another good thing that this method are dependency check, for example:

# models
#  \-- a.rb => require something of b.rb
#  \-- b.rb

In the example above if we do:

Dir["/models/*.rb"].each { |r| require r }

We get an error, because we try to require first a.rb that need something of b.rb.

With this method we don't have this problem.

Examples:

For require all our app libs we need to do:
require_dependencies("#{Padrino.root}/lib/**/*.rb")

Parameters:

  • paths (Array<String>) — The paths to require.

© 2010–2020 Padrino
Licensed under the MIT License.
https://www.rubydoc.info/github/padrino/padrino-framework/Padrino/Loader