module Hanami::Action::Glue

Glue code for full stack Hanami applications

This includes missing rendering logic that it makes sense to include only for web applications.

@api private @since 0.3.0

Constants

ADDITIONAL_HTTP_STATUSES_WITHOUT_BODY

@api private @since 0.3.2

ENV_KEY

Rack environment key that indicates where the action instance is passed

@api private @since 0.3.0

Public Class Methods

included(base) click to toggle source

Override Ruby's Module#included

@api private @since 0.3.0

# File lib/hanami/action/glue.rb, line 25
def self.included(base)
  base.class_eval { _expose(:format) if respond_to?(:_expose) }
end

Public Instance Methods

renderable?() click to toggle source

Check if the current HTTP request is renderable.

It verifies if the verb isn't HEAD, if the status demands to omit the body and if it isn't sending a file.

@return [TrueClass,FalseClass] the result of the check

@api private @since 0.3.2

# File lib/hanami/action/glue.rb, line 38
def renderable?
  !_requires_no_body? &&
    !sending_file?    &&
    !ADDITIONAL_HTTP_STATUSES_WITHOUT_BODY.include?(@_status)
end

Protected Instance Methods

finish() click to toggle source

Put the current instance into the Rack environment

@api private @since 0.3.0

@see Hanami::Action#finish

Calls superclass method
# File lib/hanami/action/glue.rb, line 51
def finish
  super
  @_env[ENV_KEY] = self
end
sending_file?() click to toggle source

Check if the request's body is a file

@return [TrueClass,FalseClass] the result of the check

@since 0.4.3

# File lib/hanami/action/glue.rb, line 61
def sending_file?
  @_body.is_a?(::Rack::File::Iterator)
end