Class: Volt::App

Inherits:
Object show all
Includes:
ServerSetup::App
Defined in:
lib/volt/volt/app.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ServerSetup::App

#load_app_code, #require_http_controllers, #reset_query_pool!, #run_app_and_initializers, #run_config, #setup_paths, #setup_postboot_middleware, #setup_preboot_middleware, #setup_router, #start_message_bus

Constructor Details

#initialize(app_path = nil) ⇒ App

Returns a new instance of App.



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/volt/volt/app.rb', line 44

def initialize(app_path=nil)
  if Volt.server? && !app_path
    raise "Volt::App.new requires an app path to boot"
  end

  @app_path = app_path
  $volt_app = self

  # Setup root path
  Volt.root = app_path

  setup_page

  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'

    # 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

    reset_query_pool!

    # Setup the middleware that we can only setup after all components boot.
    setup_postboot_middleware

    start_message_bus
  end
end

Instance Attribute Details

#app_pathObject (readonly)

Returns the value of attribute app_path.



39
40
41
# File 'lib/volt/volt/app.rb', line 39

def app_path
  @app_path
end

#channel_live_queriesObject (readonly)

Returns the value of attribute channel_live_queries.



39
40
41
# File 'lib/volt/volt/app.rb', line 39

def channel_live_queries
  @channel_live_queries
end

#component_pathsObject (readonly)

Returns the value of attribute component_paths.



39
40
41
# File 'lib/volt/volt/app.rb', line 39

def component_paths
  @component_paths
end

#databaseObject (readonly)

Returns the value of attribute database.



39
40
41
# File 'lib/volt/volt/app.rb', line 39

def database
  @database
end

#live_query_poolObject (readonly)

Returns the value of attribute live_query_pool.



39
40
41
# File 'lib/volt/volt/app.rb', line 39

def live_query_pool
  @live_query_pool
end

#message_busObject (readonly)

Returns the value of attribute message_bus.



39
40
41
# File 'lib/volt/volt/app.rb', line 39

def message_bus
  @message_bus
end

#middlewareObject (readonly)

Returns the value of attribute middleware.



39
40
41
# File 'lib/volt/volt/app.rb', line 39

def middleware
  @middleware
end

#pageObject (readonly)

Returns the value of attribute page.



39
40
41
# File 'lib/volt/volt/app.rb', line 39

def page
  @page
end

#routerObject (readonly)

Returns the value of attribute router.



39
40
41
# File 'lib/volt/volt/app.rb', line 39

def router
  @router
end

#sprocketsObject

Returns the value of attribute sprockets.



42
43
44
# File 'lib/volt/volt/app.rb', line 42

def sprockets
  @sprockets
end

Instance Method Details

#setup_pageObject

Setup a Page instance.



91
92
93
94
95
96
97
# File 'lib/volt/volt/app.rb', line 91

def setup_page
  # Run the app config to load all users config files
  @page = Page.new(self)

  # Setup a global for now
  $page = @page unless defined?($page)
end