Class: Flame::Application
- Inherits:
-
Object
- Object
- Flame::Application
- Defined in:
- lib/flame/application.rb
Overview
Core class, like Framework::Application
Defined Under Namespace
Classes: Config
Class Attribute Summary collapse
-
.config ⇒ Object
Returns the value of attribute config.
Class Method Summary collapse
- .call(env) ⇒ Object
- .default_config_dirs(root_dir:) ⇒ Object
- .helpers(*modules) ⇒ Object
- .inherited(app) ⇒ Object
- .mount(ctrl, path = nil, &block) ⇒ Object
-
.router ⇒ Object
Router for routing.
Instance Method Summary collapse
-
#call(env) ⇒ Object
Init function.
-
#config ⇒ Object
Framework configuration.
Class Attribute Details
.config ⇒ Object
Returns the value of attribute config.
9 10 11 |
# File 'lib/flame/application.rb', line 9 def config @config end |
Class Method Details
.call(env) ⇒ Object
28 29 30 31 |
# File 'lib/flame/application.rb', line 28 def self.call(env) @app ||= new @app.call env end |
.default_config_dirs(root_dir:) ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/flame/application.rb', line 51 def self.default_config_dirs(root_dir:) { root_dir: File.realpath(root_dir), public_dir: proc { File.join(config[:root_dir], 'public') }, views_dir: proc { File.join(config[:root_dir], 'views') }, config_dir: proc { File.join(config[:root_dir], 'config') } } end |
.helpers(*modules) ⇒ Object
42 43 44 |
# File 'lib/flame/application.rb', line 42 def self.helpers(*modules) modules.empty? ? (@helpers ||= []) : @helpers = modules end |
.inherited(app) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/flame/application.rb', line 17 def self.inherited(app) app.config = Config.new( app, default_config_dirs( root_dir: File.dirname(caller[0].split(':')[0]) ).merge( environment: ENV['RACK_ENV'] || 'development' ) ) end |
.mount(ctrl, path = nil, &block) ⇒ Object
38 39 40 |
# File 'lib/flame/application.rb', line 38 def self.mount(ctrl, path = nil, &block) router.add_controller(ctrl, path, block) end |
Instance Method Details
#call(env) ⇒ Object
Init function
34 35 36 |
# File 'lib/flame/application.rb', line 34 def call(env) Flame::Dispatcher.new(self, env).run! end |
#config ⇒ Object
Framework configuration
13 14 15 |
# File 'lib/flame/application.rb', line 13 def config self.class.config end |