class Flame::Application
Core class, like Framework::Application
Attributes
config[RW]
Public Class Methods
cached_tilts()
click to toggle source
# File lib/flame/application.rb, line 18 def cached_tilts @cached_tilts ||= {} end
call(env)
click to toggle source
Make available `run Application` without `.new` for `rackup`
# File lib/flame/application.rb, line 35 def call(env) @app ||= new @app.call env end
inherited(app)
click to toggle source
Generating application config when inherited
# File lib/flame/application.rb, line 23 def 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
new(app = nil)
click to toggle source
# File lib/flame/application.rb, line 79 def initialize(app = nil) @app = app end
router()
click to toggle source
Router
for routing
# File lib/flame/application.rb, line 14 def router @router ||= Flame::Router.new(self) end
Private Class Methods
default_config_dirs(root_dir:)
click to toggle source
Initialize default for config directories
# File lib/flame/application.rb, line 61 def default_config_dirs(root_dir:) result = { root_dir: File.realpath(root_dir) } %i[public views config tmp].each do |key| result[:"#{key}_dir"] = proc { File.join(config[:root_dir], key.to_s) } end result end
mount(ctrl, path = nil, &block)
click to toggle source
Mount controller in application class @param ctrl [Flame::Controller] the mounted controller class @param path [String, nil] root path for the mounted controller @yield refine defaults pathes for a methods of the mounted controller @example Mount controller with defaults
mount ArticlesController
@example Mount controller with specific path
mount HomeController, '/welcome'
@example Mount controller with specific path of methods
mount HomeController do get '/bye', :goodbye post '/greetings', :new defaults end
# File lib/flame/application.rb, line 56 def mount(ctrl, path = nil, &block) router.add_controller(ctrl, path, &block) end
Public Instance Methods
call(env)
click to toggle source
Request recieving method
# File lib/flame/application.rb, line 84 def call(env) @app.call(env) if @app.respond_to? :call Flame::Dispatcher.new(self, env).run! end
config()
click to toggle source
Framework configuration
# File lib/flame/application.rb, line 71 def config self.class.config end
router()
click to toggle source
# File lib/flame/application.rb, line 75 def router self.class.router end