Class: Kangaru::Application
- Inherits:
-
Object
- Object
- Kangaru::Application
- Extended by:
- Forwardable
- Defined in:
- lib/kangaru/application.rb
Instance Attribute Summary collapse
-
#database ⇒ Object
readonly
Returns the value of attribute database.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#paths ⇒ Object
readonly
Returns the value of attribute paths.
Instance Method Summary collapse
- #apply_config! ⇒ Object
-
#config ⇒ Object
Lazy-loaded to allow defaults to be set after application is created.
-
#configure(env = nil, &block) ⇒ Object
If called with no env, the config will be applied regardless of current env.
- #configured? ⇒ Boolean
-
#initialize(source:, namespace:) ⇒ Application
constructor
A new instance of Application.
- #run!(*argv) ⇒ Object
Constructor Details
#initialize(source:, namespace:) ⇒ Application
Returns a new instance of Application.
7 8 9 10 11 12 |
# File 'lib/kangaru/application.rb', line 7 def initialize(source:, namespace:) @paths = Paths.new(source:) @namespace = namespace autoloader.setup end |
Instance Attribute Details
#database ⇒ Object (readonly)
Returns the value of attribute database.
5 6 7 |
# File 'lib/kangaru/application.rb', line 5 def database @database end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
5 6 7 |
# File 'lib/kangaru/application.rb', line 5 def namespace @namespace end |
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
5 6 7 |
# File 'lib/kangaru/application.rb', line 5 def paths @paths end |
Instance Method Details
#apply_config! ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/kangaru/application.rb', line 30 def apply_config! raise "config already applied" if configured? config.import_external_config! @database = setup_database! @configured = true end |
#config ⇒ Object
Lazy-loaded to allow defaults to be set after application is created.
15 16 17 |
# File 'lib/kangaru/application.rb', line 15 def config @config ||= Config.new end |
#configure(env = nil, &block) ⇒ Object
If called with no env, the config will be applied regardless of current env. If multiple configure calls matching the current env are made, the most recent calls will overwrite older changes.
22 23 24 |
# File 'lib/kangaru/application.rb', line 22 def configure(env = nil, &block) block.call(config) if current_env?(env) end |
#configured? ⇒ Boolean
26 27 28 |
# File 'lib/kangaru/application.rb', line 26 def configured? @configured == true end |