class Volt::App
Attributes
app_path[R]
browser[R]
channel_live_queries[R]
component_paths[R]
database[R]
live_query_pool[R]
message_bus[R]
middleware[R]
opal_files[RW]
router[R]
sprockets[RW]
Public Class Methods
new(app_path=nil)
click to toggle source
# File lib/volt/volt/app.rb, line 55 def initialize(app_path=nil) app_path ||= Dir.pwd if Volt.server? && !app_path raise "Volt::App.new requires an app path to boot" end # Expand to a full path app_path = File.expand_path(app_path) @app_path = app_path $volt_app = self # Setup root path Volt.root = app_path if RUBY_PLATFORM == 'opal' setup_browser end if RUBY_PLATFORM != 'opal' # We need to run the root config first so we can setup the Rack::Session # middleware. run_config # Setup all of the middleware we can before we load the users components # since the users components might want to add middleware during boot. setup_preboot_middleware # Setup all app paths setup_paths # Require in app and initializers run_app_and_initializers unless RUBY_PLATFORM == 'opal' require_components # abort_on_exception is a useful debugging tool, and in my opinion something # you probbaly want on. That said you can disable it if you need. unless RUBY_PLATFORM == 'opal' Thread.abort_on_exception = Volt.config.abort_on_exception end load_app_code # Load up the main component dependencies. This is needed to load in # any opal_gem calls in dependencies.rb # TODO: Needs to support all components if Dir.exists?(Volt.root + '/app/main') AssetFiles.from_cache(app_url, 'main', component_paths) end reset_query_pool! # Setup the middleware that we can only setup after all components boot. setup_postboot_middleware setup_routes start_message_bus end end
Public Instance Methods
add_routes(&block)
click to toggle source
Called on the client side to add routes
# File lib/volt/volt/app.rb, line 123 def add_routes(&block) @router ||= Routes.new @router.define(&block) url.router = @router end
add_template(*args)
click to toggle source
Callled on the client to add store compiled templates
# File lib/volt/volt/app.rb, line 130 def add_template(*args) templates.add_template(*args) end
channel()
click to toggle source
# File lib/volt/volt/app.rb, line 138 def channel @channel ||= begin if Volt.client? Channel.new else ChannelStub.new end end end
setup_browser()
click to toggle source
Setup a Page instance.
# File lib/volt/volt/app.rb, line 149 def setup_browser @browser = Browser.new(self) end
tasks()
click to toggle source
# File lib/volt/volt/app.rb, line 134 def tasks @tasks ||= Tasks.new(self) end
templates()
click to toggle source
# File lib/volt/volt/app.rb, line 118 def templates @templates ||= Templates.new end