Class: Tzispa::Application
- Inherits:
-
Object
- Object
- Tzispa::Application
- Extended by:
- Forwardable
- Includes:
- Engine
- Defined in:
- lib/tzispa/app.rb
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.
52 53 54 55 56 57 |
# File 'lib/tzispa/app.rb', line 52 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.
19 20 21 |
# File 'lib/tzispa/app.rb', line 19 def domain @domain end |
#engine ⇒ Object (readonly)
Returns the value of attribute engine.
19 20 21 |
# File 'lib/tzispa/app.rb', line 19 def engine @engine end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
19 20 21 |
# File 'lib/tzispa/app.rb', line 19 def logger @logger end |
#map_path ⇒ Object (readonly)
Returns the value of attribute map_path.
19 20 21 |
# File 'lib/tzispa/app.rb', line 19 def map_path @map_path end |
#routes ⇒ Object (readonly)
Returns the value of attribute routes.
19 20 21 |
# File 'lib/tzispa/app.rb', line 19 def routes @routes end |
Class Method Details
.[](name) ⇒ Object
40 41 42 |
# File 'lib/tzispa/app.rb', line 40 def [](name) applications[name] end |
.__new__ ⇒ Object
23 |
# File 'lib/tzispa/app.rb', line 23 alias __new__ :new |
.add(app) ⇒ Object
44 45 46 47 48 49 |
# File 'lib/tzispa/app.rb', line 44 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
30 31 32 33 34 |
# File 'lib/tzispa/app.rb', line 30 def applications synchronize do @@applications ||= Hash.new { |_, key| raise UnknownApplication(key.to_s) } end end |
.new(*args, &block) ⇒ Object
25 26 27 |
# File 'lib/tzispa/app.rb', line 25 def new(*args, &block) __new__(*args, &block).tap { |app| add app } end |
.synchronize ⇒ Object
36 37 38 |
# File 'lib/tzispa/app.rb', line 36 def synchronize Mutex.new.synchronize { yield } end |
Instance Method Details
#[](domain) ⇒ Object
75 76 77 |
# File 'lib/tzispa/app.rb', line 75 def [](domain) self.class[domain] end |
#call(env) ⇒ Object
59 60 61 |
# File 'lib/tzispa/app.rb', line 59 def call(env) routes.call env end |
#config ⇒ Object
83 84 85 |
# File 'lib/tzispa/app.rb', line 83 def config @config ||= Config::AppConfig.new(@domain).load! end |
#env ⇒ Object
79 80 81 |
# File 'lib/tzispa/app.rb', line 79 def env Tzispa::Environment.instance end |
#load! ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/tzispa/app.rb', line 63 def load! tap do |app| app.class.synchronize do logging_setup locales_setup repository&.load!(domain) domain.setup routes_setup end end end |