Class: Flame::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/flame/application.rb,
lib/flame/application/config.rb

Overview

Core class, like Framework::Application

Defined Under Namespace

Classes: Config

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app = nil) ⇒ Application

Returns a new instance of Application.



79
80
81
# File 'lib/flame/application.rb', line 79

def initialize(app = nil)
	@app = app
end

Class Attribute Details

.configObject

Returns the value of attribute config.



11
12
13
# File 'lib/flame/application.rb', line 11

def config
  @config
end

Class Method Details

.cached_tiltsObject



18
19
20
# File 'lib/flame/application.rb', line 18

def cached_tilts
	@cached_tilts ||= {}
end

.call(env) ⇒ Object

Make available ‘run Application` without `.new` for `rackup`



35
36
37
38
# File 'lib/flame/application.rb', line 35

def call(env)
	@app ||= new
	@app.call env
end

.inherited(app) ⇒ Object

Generating application config when inherited



23
24
25
26
27
28
29
30
31
32
# 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

.routerObject

Router for routing



14
15
16
# File 'lib/flame/application.rb', line 14

def router
	@router ||= Flame::Router.new(self)
end

Instance Method Details

#call(env) ⇒ Object

Request recieving method



84
85
86
87
# 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

#configObject

Framework configuration



71
72
73
# File 'lib/flame/application.rb', line 71

def config
	self.class.config
end

#routerObject



75
76
77
# File 'lib/flame/application.rb', line 75

def router
	self.class.router
end