Class: MVCLI::Middleware
- Inherits:
-
Object
show all
- Defined in:
- lib/mvcli/middleware.rb,
lib/mvcli/middleware/exit_status.rb,
lib/mvcli/middleware/exception_logger.rb,
lib/mvcli/middleware/exception_logger/validation_summary.rb
Defined Under Namespace
Classes: ExceptionLogger, ExitStatus
Instance Method Summary
collapse
Constructor Details
#initialize {|_self| ... } ⇒ Middleware
Returns a new instance of Middleware.
3
4
5
6
|
# File 'lib/mvcli/middleware.rb', line 3
def initialize
@apps = []
yield self if block_given?
end
|
Instance Method Details
#<<(app) ⇒ Object
28
29
30
|
# File 'lib/mvcli/middleware.rb', line 28
def <<(app)
@apps << app
end
|
#[](idx) ⇒ Object
20
21
22
|
# File 'lib/mvcli/middleware.rb', line 20
def [](idx)
@apps[idx]
end
|
#[]=(idx, app) ⇒ Object
24
25
26
|
# File 'lib/mvcli/middleware.rb', line 24
def []=(idx, app)
@apps[idx] = app
end
|
#call(command, apps = @apps, &block) ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/mvcli/middleware.rb', line 8
def call(command, apps = @apps, &block)
app, *rest = apps + [block].compact
if app
app.call(command) do |yielded|
yielded ||= command
call yielded, rest
end
else
return 0
end
end
|
#length ⇒ Object
32
33
34
|
# File 'lib/mvcli/middleware.rb', line 32
def length
@apps.length
end
|