Sha256: e972cdaea653fc39bcc400127605bc1cc13ae6f21918dd3414414d79e39aaa70
Contents?: true
Size: 1.05 KB
Versions: 1
Compression:
Stored size: 1.05 KB
Contents
module RocketIO class Controller # storing Rack middleware to be called when a request handled by controller # # @note middleware is inheritable # # @example add a middleware to be used in current controller # and any controllers that inherits from it # # class Users < RocketIO::Controller # use Rack::CommonLogger # end # # @param w [Class, Proc] a valid Rack middleware that responds to `call` # @param *a [Array] any args to be passed at middleware initialization # @param &b [Proc] a block to be yielded at middleware initialization # def self.use w = nil, *a, &b (@__middleware__ ||= []).push(proc {|app| w.new(app, *a, &b)}) define_middleware_methods end def self.define_middleware_methods source = self middleware = ((source.instance_variable_get(:@__middleware__) || []) + allocate.middleware).uniq.freeze return if middleware.empty? private_api << define_method(:middleware) {middleware} end def middleware; RocketIO::EMPTY_ARRAY end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rocketio-0.1.0 | lib/rocketio/controller/middleware.rb |