Class: Ovto::App
- Inherits:
-
Object
- Object
- Ovto::App
- Defined in:
- lib/ovto/app.rb
Instance Attribute Summary collapse
-
#main_component ⇒ Object
readonly
An instance of YourApp::MainComponent (mainly for testing).
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Class Method Summary collapse
-
.middlewares ⇒ Object
List of installed middleware classes.
-
.run(*args) ⇒ Object
Create an App and start it.
-
.use(middleware_class) ⇒ Object
Install a middleware.
Instance Method Summary collapse
-
#_set_state(new_state) ⇒ Object
Internal use only.
- #actions ⇒ Object
-
#initialize ⇒ App
constructor
A new instance of App.
-
#run(*args) ⇒ Object
Start this app.
-
#setup ⇒ Object
Called when this app is started.
Constructor Details
#initialize ⇒ App
Returns a new instance of App.
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ovto/app.rb', line 18 def initialize app_state_class = self.class.const_get('State') # Inject middleware states app_state_class.item :_middlewares, default_proc: ->{ Ovto::Middleware.create_middleware_states_class(self.class.middlewares).new } @state = app_state_class.new @wired_action_set = nil @main_component = nil end |
Instance Attribute Details
#main_component ⇒ Object (readonly)
An instance of YourApp::MainComponent (mainly for testing)
31 32 33 |
# File 'lib/ovto/app.rb', line 31 def main_component @main_component end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
28 29 30 |
# File 'lib/ovto/app.rb', line 28 def state @state end |
Class Method Details
.middlewares ⇒ Object
List of installed middleware classes
4 5 6 |
# File 'lib/ovto/app.rb', line 4 def self.middlewares @middlewares ||= [] end |
.run(*args) ⇒ Object
Create an App and start it
9 10 11 |
# File 'lib/ovto/app.rb', line 9 def self.run(*args) new.run(*args) end |
.use(middleware_class) ⇒ Object
Install a middleware
14 15 16 |
# File 'lib/ovto/app.rb', line 14 def self.use(middleware_class) self.middlewares.push(middleware_class) end |
Instance Method Details
#_set_state(new_state) ⇒ Object
Internal use only
38 39 40 |
# File 'lib/ovto/app.rb', line 38 def _set_state(new_state) @state = new_state end |
#actions ⇒ Object
33 34 35 |
# File 'lib/ovto/app.rb', line 33 def actions @wired_action_set.app_wired_actions end |
#run(*args) ⇒ Object
Start this app
43 44 45 |
# File 'lib/ovto/app.rb', line 43 def run(*args) Ovto.log_error{ _run(*args) } end |
#setup ⇒ Object
Called when this app is started
48 49 50 |
# File 'lib/ovto/app.rb', line 48 def setup # override this if needed end |