lib/hanami/action/rack.rb in hanami-controller-0.6.1 vs lib/hanami/action/rack.rb in hanami-controller-0.7.0
- old
+ new
@@ -1,7 +1,8 @@
require 'securerandom'
require 'hanami/action/request'
+require 'hanami/action/base_params'
require 'hanami/action/rack/callable'
require 'hanami/action/rack/file'
module Hanami
module Action
@@ -49,11 +50,14 @@
# @since 0.1.0
# @api private
#
# @see http://www.ruby-doc.org/core-2.1.2/Module.html#method-i-included
def self.included(base)
- base.extend ClassMethods
+ base.class_eval do
+ extend ClassMethods
+ prepend InstanceMethods
+ end
end
module ClassMethods
# Build rack builder
#
@@ -64,10 +68,11 @@
rack_builder = ::Rack::Builder.new
rack_builder.run ->(env) { self.new.call(env) }
rack_builder
end
end
+
# Use a Rack middleware
#
# The middleware will be used as it is.
#
# At the runtime, the middleware be invoked with the raw Rack env.
@@ -95,9 +100,35 @@
# end
# end
# end
def use(middleware, *args, &block)
rack_builder.use middleware, *args, &block
+ end
+
+ # Returns the class which defines the params
+ #
+ # Returns the class which has been provided to define the
+ # params. By default this will be Hanami::Action::Params.
+ #
+ # @return [Class] A params class (when whitelisted) or
+ # Hanami::Action::Params
+ #
+ # @api private
+ # @since 0.7.0
+ def params_class
+ @params_class ||= BaseParams
+ end
+ end
+
+ # @since 0.7.0
+ # @api private
+ module InstanceMethods
+ # @since 0.7.0
+ # @api private
+ def initialize(*)
+ super
+ @_status = nil
+ @_body = nil
end
end
protected
# Gets the headers from the response