Module: Volt::ServerSetup::App
- Includes:
- Eventable
- Included in:
- App
- Defined in:
- lib/volt/volt/server_setup/app.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Eventable
#on, #remove_listener, #trigger!
Instance Attribute Details
The app url is where the app folder (and sprockets) is mounted
19
20
21
|
# File 'lib/volt/volt/server_setup/app.rb', line 19
def app_url
@app_url
end
|
The root url is where the volt app is mounted
17
18
19
|
# File 'lib/volt/volt/server_setup/app.rb', line 17
def root_url
@root_url
end
|
Instance Method Details
#load_app_code ⇒ Object
31
32
33
34
35
36
37
|
# File 'lib/volt/volt/server_setup/app.rb', line 31
def load_app_code
setup_router
require_http_controllers
@root_url = '/'
@app_url = '/app'
end
|
#require_components ⇒ Object
27
28
29
|
# File 'lib/volt/volt/server_setup/app.rb', line 27
def require_components
@component_paths.require_in_components(self)
end
|
#require_http_controllers ⇒ Object
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/volt/volt/server_setup/app.rb', line 68
def require_http_controllers
@component_paths.app_folders do |app_folder|
Dir["#{app_folder}/*/controllers/server/*.rb"].each do |ruby_file|
require(ruby_file)
end
end
end
|
#reset_query_pool! ⇒ Object
106
107
108
109
110
111
112
113
114
115
116
|
# File 'lib/volt/volt/server_setup/app.rb', line 106
def reset_query_pool!
if RUBY_PLATFORM != 'opal'
require 'volt/tasks/live_query/live_query_pool'
@database = Volt::DataStore.fetch
@live_query_pool = LiveQueryPool.new(@database, self)
@channel_live_queries = {}
end
end
|
#run_app_and_initializers ⇒ Object
Load in all .rb files in the initializers folders and the config/app.rb file.
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
# File 'lib/volt/volt/server_setup/app.rb', line 87
def run_app_and_initializers
files = []
files += Dir[Volt.root + '/config/initializers/*.rb']
files += Dir[Volt.root + '/config/initializers/server/*.rb']
component_paths.app_folders do |app_folder|
files += Dir["#{app_folder}/*/config/initializers/*.rb"]
files += Dir["#{app_folder}/*/config/initializers/server/*.rb"]
end
files.each do |initializer|
require(initializer)
end
end
|
#run_config ⇒ Object
This config needs to run earlier than others
80
81
82
83
|
# File 'lib/volt/volt/server_setup/app.rb', line 80
def run_config
path = "#{Volt.root}/config/app.rb"
require(path) if File.exists?(path)
end
|
#setup_paths ⇒ Object
21
22
23
24
25
|
# File 'lib/volt/volt/server_setup/app.rb', line 21
def setup_paths
@component_paths = ComponentPaths.new(@app_path)
@component_paths.setup_load_paths
end
|
#setup_postboot_middleware ⇒ Object
#setup_preboot_middleware ⇒ Object
#setup_router ⇒ Object
39
40
41
|
# File 'lib/volt/volt/server_setup/app.rb', line 39
def setup_router
@router = Routes.new
end
|
#setup_routes ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/volt/volt/server_setup/app.rb', line 43
def setup_routes
component_paths = @component_paths
@router.define do
component_paths.components.values.flatten.uniq.each do |component_path|
routes_path = "#{component_path}/config/routes.rb"
if File.exist?(routes_path)
route_file = File.read(routes_path)
instance_eval(route_file, routes_path, 0)
end
end
end
end
|
#start_message_bus ⇒ Object
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
# File 'lib/volt/volt/server_setup/app.rb', line 118
def start_message_bus
return if ENV['NO_MESSAGE_BUS']
unless RUBY_PLATFORM == 'opal'
unless Volt.env.test?
bus_name = Volt.config.message_bus.try(:bus_name) || 'peer_to_peer'
begin
message_bus_class = MessageBus.const_get(bus_name.camelize)
rescue NameError => e
raise "message bus name #{bus_name} was not found, be sure its "
+ "gem is included in the gemfile."
end
@message_bus = message_bus_class.new(self)
Thread.new do
@message_bus.subscribe('volt_collection_update') do |collection_name|
live_query_pool.updated_collection(collection_name, nil, true)
end
end
end
end
end
|