class EndpointFlux::Config::Middleware
Attributes
handler[RW]
klass[RW]
options[RW]
Public Class Methods
new(klass = nil, options = {}, &block)
click to toggle source
# File lib/endpoint_flux/config/middleware.rb, line 6 def initialize(klass = nil, options = {}, &block) if klass unless klass.methods.include?(:perform) raise "The [#{klass}] class should define perform class method" end else raise 'You must provide block or existing klass' unless block_given? end @klass = klass @options = options @handler = block end
Public Instance Methods
==(other)
click to toggle source
# File lib/endpoint_flux/config/middleware.rb, line 30 def ==(other) return true if klass && klass == other.klass return true if handler && handler == other.handler false end
run(attrs)
click to toggle source
# File lib/endpoint_flux/config/middleware.rb, line 20 def run(attrs) if klass klass.perform(*attrs, options, &handler) elsif handler handler.call(*attrs, options) else raise "Unknown middleware type [#{inspect}]" end end