Sha256: 54fb1c3ed8aead6967e37f28df8200b8b0a82a724b0a1cba587953414e876f31

Contents?: true

Size: 831 Bytes

Versions: 19

Compression:

Stored size: 831 Bytes

Contents

# frozen-string-literal: true

class Roda
  module RodaPlugins
    # The symbol_status plugin patches the +status=+ response method to
    # accept the status name as a symbol.  If given an integer value,
    # the default behaviour is used.
    #
    # Examples:
    #   r.is "needs_authorization"
    #     response.status = :unauthorized
    #   end
    #   r.is "nothing"
    #     response.status = :no_content
    #   end
    #
    # The conversion is done through <tt>Rack::Utils.status_code</tt>.
    module SymbolStatus
      module ResponseMethods
        # Sets the response status code by fixnum or symbol name
        def status=(code)
          code = Rack::Utils.status_code(code) if code.is_a?(Symbol)
          super(code)
        end
      end
    end

    register_plugin(:symbol_status, SymbolStatus)
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
roda-3.2.0 lib/roda/plugins/symbol_status.rb
roda-3.1.0 lib/roda/plugins/symbol_status.rb
roda-3.0.0 lib/roda/plugins/symbol_status.rb
roda-2.29.0 lib/roda/plugins/symbol_status.rb
roda-2.28.0 lib/roda/plugins/symbol_status.rb
roda-2.27.0 lib/roda/plugins/symbol_status.rb
roda-2.26.0 lib/roda/plugins/symbol_status.rb
roda-2.25.0 lib/roda/plugins/symbol_status.rb
roda-2.24.0 lib/roda/plugins/symbol_status.rb
roda-2.23.0 lib/roda/plugins/symbol_status.rb
roda-2.22.0 lib/roda/plugins/symbol_status.rb
roda-2.21.0 lib/roda/plugins/symbol_status.rb
roda-2.20.0 lib/roda/plugins/symbol_status.rb
roda-2.19.0 lib/roda/plugins/symbol_status.rb
roda-2.18.0 lib/roda/plugins/symbol_status.rb
roda-2.17.0 lib/roda/plugins/symbol_status.rb
roda-2.16.0 lib/roda/plugins/symbol_status.rb
roda-2.15.0 lib/roda/plugins/symbol_status.rb
roda-2.14.0 lib/roda/plugins/symbol_status.rb