Class: Ovto::Middleware::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/ovto/middleware.rb

Overview

Base class of a middleware class Note: this is not the direct superclass of a middleware. `SomeMiddleware < (anonymous class) < Middleware::Base`

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(wired_actions) ⇒ Base

Returns a new instance of Base.



73
74
75
# File 'lib/ovto/middleware.rb', line 73

def initialize(wired_actions)
  @wired_actions = wired_actions
end

Class Method Details

._run_setup(wired_action_set) ⇒ Object



65
66
67
68
69
70
71
# File 'lib/ovto/middleware.rb', line 65

def self._run_setup(wired_action_set)
  mw = new(wired_action_set[WiredActionSet::THE_MIDDLEWARE_ITSELF])
  mw.setup
  self.middlewares.each do |m|
    m._run_setup(wired_action_set[m.name])
  end
end

.middlewaresObject

Nested middlewares



51
52
53
# File 'lib/ovto/middleware.rb', line 51

def self.middlewares
  @middlewares ||= []
end

.nameObject

Middleware name (set by Ovto.Middleware)



61
62
63
# File 'lib/ovto/middleware.rb', line 61

def self.name
  const_get(:OVTO_MIDDLEWARE_NAME)
end

.use(middleware_class) ⇒ Object

Install a nested middleware



56
57
58
# File 'lib/ovto/middleware.rb', line 56

def self.use(middleware_class)
  self.middlewares.push(middleware_class)
end

Instance Method Details

#actionsObject



81
82
83
# File 'lib/ovto/middleware.rb', line 81

def actions
  @wired_actions
end

#setupObject

Override this if needed



78
79
# File 'lib/ovto/middleware.rb', line 78

def setup
end