Module: Rage
- Defined in:
- lib/rage-rb.rb,
lib/rage/cli.rb,
lib/rage/version.rb
Defined Under Namespace
Modules: Errors, Ext, Router
Classes: Application, CLI, CodeLoader, Configuration, Cookies, Cors, Env, FiberScheduler, FiberWrapper, JSONFormatter, Logger, NewAppGenerator, ParamsParser, Reloader, Request, Response, Session, SidekiqSession, TextFormatter, UploadedFile
Constant Summary
collapse
- VERSION =
"1.5.0"
Class Method Summary
collapse
Class Method Details
.__router ⇒ Object
35
36
37
|
# File 'lib/rage-rb.rb', line 35
def self.__router
@__router ||= Rage::Router::Backend.new
end
|
.application ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/rage-rb.rb', line 9
def self.application
app = Application.new(__router)
config.middleware.middlewares.reverse.inject(app) do |next_in_chain, (middleware, args, block)|
if Rage.config.internal.rails_mode
rails_middleware = Rails.application.config.middleware.middlewares.find { |m| m.name == middleware.name }
end
if rails_middleware
rails_middleware.build(next_in_chain)
else
middleware.new(next_in_chain, *args, &block)
end
end
end
|
.code_loader ⇒ Object
68
69
70
|
# File 'lib/rage-rb.rb', line 68
def self.code_loader
@code_loader ||= Rage::CodeLoader.new
end
|
.config ⇒ Object
39
40
41
|
# File 'lib/rage-rb.rb', line 39
def self.config
@config ||= Rage::Configuration.new
end
|
43
44
45
46
|
# File 'lib/rage-rb.rb', line 43
def self.configure(&)
config.instance_eval(&)
config.__finalize
end
|
.env ⇒ Object
48
49
50
|
# File 'lib/rage-rb.rb', line 48
def self.env
@__env ||= Rage::Env.new(ENV["RAGE_ENV"] || ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development")
end
|
.groups ⇒ Object
52
53
54
|
# File 'lib/rage-rb.rb', line 52
def self.groups
[:default, Rage.env.to_sym]
end
|
.load_middlewares(_) ⇒ Object
64
65
66
|
# File 'lib/rage-rb.rb', line 64
def self.load_middlewares(_)
puts "`Rage.load_middlewares` is deprecated and has been merged into `Rage.application`. Please remove this call."
end
|
.logger ⇒ Object
60
61
62
|
# File 'lib/rage-rb.rb', line 60
def self.logger
@logger ||= config.logger
end
|
.multi_application ⇒ Object
27
28
29
|
# File 'lib/rage-rb.rb', line 27
def self.multi_application
Rage::Router::Util::Cascade.new(application, Rails.application)
end
|
.patch_active_record_connection_pool ⇒ Object
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/rage-rb.rb', line 72
def self.patch_active_record_connection_pool
patch = proc do
is_connected = ActiveRecord::Base.connection_pool rescue false
if is_connected
puts "INFO: Patching ActiveRecord::ConnectionPool"
Iodine.on_state(:on_start) do
ActiveRecord::Base.connection_pool.extend(Rage::Ext::ActiveRecord::ConnectionPool)
ActiveRecord::Base.connection_pool.__init_rage_extension
end
else
puts "WARNING: DB connection is not established - can't patch ActiveRecord::ConnectionPool"
end
end
if Rage.config.internal.rails_mode
Rails.configuration.after_initialize(&patch)
else
patch.call
end
end
|
.root ⇒ Object
56
57
58
|
# File 'lib/rage-rb.rb', line 56
def self.root
@root ||= Pathname.new(".").expand_path
end
|
.routes ⇒ Object
31
32
33
|
# File 'lib/rage-rb.rb', line 31
def self.routes
Rage::Router::DSL.new(__router)
end
|