Module: Hanami::Action::Rack::ClassMethods Private

Defined in:
lib/hanami/action/rack.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0

Instance Method Summary collapse

Instance Method Details

#params_classClass

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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.

Returns:

  • (Class)

    A params class (when whitelisted) or Hanami::Action::Params

Since:

  • 0.7.0



159
160
161
# File 'lib/hanami/action/rack.rb', line 159

def params_class
  @params_class ||= BaseParams
end

#rack_builderRack::Builder

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Build rack builder

Returns:

  • (Rack::Builder)

Since:

  • 0.1.0



107
108
109
110
111
112
113
114
# File 'lib/hanami/action/rack.rb', line 107

def rack_builder
  @rack_builder ||= begin
    extend Hanami::Action::Rack::Callable
    rack_builder = ::Rack::Builder.new
    rack_builder.run ->(env) { self.new.call(env) }
    rack_builder
  end
end

#use(middleware, *args, &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Use a Rack middleware

The middleware will be used as it is.

At the runtime, the middleware be invoked with the raw Rack env.

Multiple middlewares can be employed, just by using multiple times this method.

Examples:

Middleware

require 'hanami/controller'

module Sessions
  class Create
    include Hanami::Action
    use OmniAuth

    def call(params)
      # ...
    end
  end
end

Parameters:

  • middleware (#call)

    A Rack middleware

  • args (Array)

    Array arguments for middleware

See Also:

Since:

  • 0.2.0



145
146
147
# File 'lib/hanami/action/rack.rb', line 145

def use(middleware, *args, &block)
  rack_builder.use middleware, *args, &block
end