Class: Tzispa::Application
- Inherits:
-
Object
- Object
- Tzispa::Application
- Extended by:
- Forwardable
- Includes:
- Engine
- Defined in:
- lib/tzispa/app.rb
Constant Summary collapse
- @@appmutex =
Mutex.new
Instance Attribute Summary collapse
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#engine ⇒ Object
readonly
Returns the value of attribute engine.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#map_path ⇒ Object
readonly
Returns the value of attribute map_path.
-
#routes ⇒ Object
readonly
Returns the value of attribute routes.
Class Method Summary collapse
- .[](name) ⇒ Object
- .__new__ ⇒ Object
- .add(app) ⇒ Object
-
.applications ⇒ Object
rubocop:disable Style/ClassVars.
- .new(*args, &block) ⇒ Object
- .synchronize ⇒ Object
Instance Method Summary collapse
- #[](domain) ⇒ Object
- #call(env) ⇒ Object
- #config ⇒ Object
- #env ⇒ Object
-
#initialize(appid, engine:, on: nil, &block) ⇒ Application
constructor
A new instance of Application.
- #load! ⇒ Object
- #repository ⇒ Object
Methods included from Engine
Constructor Details
#initialize(appid, engine:, on: nil, &block) ⇒ Application
Returns a new instance of Application.
61 62 63 64 65 66 |
# File 'lib/tzispa/app.rb', line 61 def initialize(appid, engine:, on: nil, &block) @domain = Domain.new(appid) @map_path = on @engine = engine instance_eval(&block) if block end |
Instance Attribute Details
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
21 22 23 |
# File 'lib/tzispa/app.rb', line 21 def domain @domain end |
#engine ⇒ Object (readonly)
Returns the value of attribute engine.
21 22 23 |
# File 'lib/tzispa/app.rb', line 21 def engine @engine end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
21 22 23 |
# File 'lib/tzispa/app.rb', line 21 def logger @logger end |
#map_path ⇒ Object (readonly)
Returns the value of attribute map_path.
21 22 23 |
# File 'lib/tzispa/app.rb', line 21 def map_path @map_path end |
#routes ⇒ Object (readonly)
Returns the value of attribute routes.
21 22 23 |
# File 'lib/tzispa/app.rb', line 21 def routes @routes end |
Class Method Details
.[](name) ⇒ Object
39 40 41 |
# File 'lib/tzispa/app.rb', line 39 def [](name) applications[name] end |
.__new__ ⇒ Object
25 |
# File 'lib/tzispa/app.rb', line 25 alias __new__ :new |
.add(app) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/tzispa/app.rb', line 43 def add(app) synchronize do raise DuplicateDomain.new(app.name) if applications.key?(app.name) applications[app.name] = app end end |
.applications ⇒ Object
rubocop:disable Style/ClassVars
32 33 34 35 36 37 |
# File 'lib/tzispa/app.rb', line 32 def applications return __applications_container if @@appmutex.locked? synchronize do __applications_container end end |
.new(*args, &block) ⇒ Object
27 28 29 |
# File 'lib/tzispa/app.rb', line 27 def new(*args, &block) __new__(*args, &block).tap { |app| add app } end |
.synchronize ⇒ Object
50 51 52 |
# File 'lib/tzispa/app.rb', line 50 def synchronize @@appmutex.synchronize { yield } end |
Instance Method Details
#[](domain) ⇒ Object
84 85 86 |
# File 'lib/tzispa/app.rb', line 84 def [](domain) self.class[domain] end |
#call(env) ⇒ Object
68 69 70 |
# File 'lib/tzispa/app.rb', line 68 def call(env) routes.call env end |
#config ⇒ Object
92 93 94 |
# File 'lib/tzispa/app.rb', line 92 def config @config ||= Config::AppConfig.new(@domain).load! end |
#env ⇒ Object
88 89 90 |
# File 'lib/tzispa/app.rb', line 88 def env Tzispa::Environment.instance end |
#load! ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/tzispa/app.rb', line 72 def load! tap do |app| app.class.synchronize do logging_setup locales_setup repository&.load!(domain) domain.setup routes_setup end end end |