Sha256: ee22d75709daf2fc0f141384379d6fb2c461f787257f3caa44fd1ca3ee18bfec
Contents?: true
Size: 1.65 KB
Versions: 3
Compression:
Stored size: 1.65 KB
Contents
module Hanami module Action # 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 module Glue # Rack environment key that indicates where the action instance is passed # # @api private # @since 0.3.0 ENV_KEY = 'hanami.action'.freeze # @api private # @since 0.3.2 ADDITIONAL_HTTP_STATUSES_WITHOUT_BODY = Set.new([301, 302]).freeze # Override Ruby's Module#included # # @api private # @since 0.3.0 def self.included(base) base.class_eval { expose(:format) if respond_to?(:expose) } end # 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 def renderable? !_requires_no_body? && !sending_file? && !ADDITIONAL_HTTP_STATUSES_WITHOUT_BODY.include?(@_status) end protected # Put the current instance into the Rack environment # # @api private # @since 0.3.0 # # @see Hanami::Action#finish def finish super @_env[ENV_KEY] = self end # Check if the request's body is a file # # @return [TrueClass,FalseClass] the result of the check # # @since 0.4.3 def sending_file? @_body.is_a?(::Rack::File) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
hanami-controller-0.7.0 | lib/hanami/action/glue.rb |
hanami-controller-0.6.1 | lib/hanami/action/glue.rb |
hanami-controller-0.6.0 | lib/hanami/action/glue.rb |