lib/raisin/api.rb in raisin-0.0.1 vs lib/raisin/api.rb in raisin-0.0.2

- old
+ new

@@ -3,22 +3,18 @@ class Middleware < ActionDispatch::MiddlewareStack::Middleware def update(args) @args = args end end - - def build(action, app=nil, &block) - super(app, &block) - end end class API - class_attribute :middleware_stack - self.middleware_stack = Raisin::MiddlewareStack.new + cattr_accessor :middleware_stack + @@middleware_stack = Raisin::MiddlewareStack.new def self.action(name, klass = ActionDispatch::Request) - middleware_stack.build(name) do |env| + middleware_stack.build do |env| self.const_get(name.camelize).new.dispatch(:call, klass.new(env)) end end def self.use(*args, &block) @@ -49,13 +45,13 @@ @_namespaces = [] @_single_resource = false end def self.inherited(subclass) + super subclass.reset subclass.middleware_stack = self.middleware_stack.dup subclass.action_klass = self.action_klass.dup - super end def self.api_name @api_name ||= self.name.demodulize.sub(/api/i, '').underscore end \ No newline at end of file