Class: Ovto::WiredActionSet
- Inherits:
-
Object
- Object
- Ovto::WiredActionSet
- Defined in:
- lib/ovto/wired_action_set.rb
Overview
Set of WiredActions (One for the app, zero or more for middlewares)
Constant Summary collapse
- I_AM_APP_NOT_A_MIDDLEWARE =
Special key for @hash
''
- THE_MIDDLEWARE_ITSELF =
''
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#middleware_names ⇒ Object
readonly
Returns the value of attribute middleware_names.
Class Method Summary collapse
-
.dummy ⇒ Object
For testing.
Instance Method Summary collapse
-
#[](name) ⇒ Object
Return the WiredActions of a middleware.
-
#app_wired_actions ⇒ Object
Return the WiredActions of the app.
-
#initialize(app, actions, middleware_path, middlewares, runtime) ⇒ WiredActionSet
constructor
A new instance of WiredActionSet.
Constructor Details
#initialize(app, actions, middleware_path, middlewares, runtime) ⇒ WiredActionSet
Returns a new instance of WiredActionSet.
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ovto/wired_action_set.rb', line 15 def initialize(app, actions, middleware_path, middlewares, runtime) @app = app @hash = {} @hash[THE_MIDDLEWARE_ITSELF] = WiredActions.new(actions, app, runtime, self) middlewares.each do |m| mw_path = middleware_path + [m.name] mw_actions = m.const_get('Actions').new(mw_path) mw_wired_action_set = WiredActionSet.new(app, mw_actions, mw_path, m.middlewares, runtime) @hash[m.name] = mw_wired_action_set mw_actions.wired_actions = mw_wired_action_set[THE_MIDDLEWARE_ITSELF] end @middleware_names = middlewares.map(&:name).to_set end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
28 29 30 |
# File 'lib/ovto/wired_action_set.rb', line 28 def app @app end |
#middleware_names ⇒ Object (readonly)
Returns the value of attribute middleware_names.
28 29 30 |
# File 'lib/ovto/wired_action_set.rb', line 28 def middleware_names @middleware_names end |
Class Method Details
.dummy ⇒ Object
For testing
11 12 13 |
# File 'lib/ovto/wired_action_set.rb', line 11 def self.dummy() new(nil, nil, [], [], nil) end |
Instance Method Details
#[](name) ⇒ Object
Return the WiredActions of a middleware
36 37 38 |
# File 'lib/ovto/wired_action_set.rb', line 36 def [](name) @hash.fetch(name) end |
#app_wired_actions ⇒ Object
Return the WiredActions of the app
31 32 33 |
# File 'lib/ovto/wired_action_set.rb', line 31 def app_wired_actions @hash[I_AM_APP_NOT_A_MIDDLEWARE] end |