Sha256: 2c634ac6e51eca37c31b614505432f6f6862d02bd36bd6635af3256e2d1ded14

Contents?: true

Size: 837 Bytes

Versions: 55

Compression:

Stored size: 837 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" do
    #     response.status = :unauthorized
    #   end
    #   r.is "nothing" do
    #     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

55 entries across 55 versions & 1 rubygems

Version Path
roda-3.55.0 lib/roda/plugins/symbol_status.rb
roda-3.54.0 lib/roda/plugins/symbol_status.rb
roda-3.53.0 lib/roda/plugins/symbol_status.rb
roda-3.52.0 lib/roda/plugins/symbol_status.rb
roda-3.51.0 lib/roda/plugins/symbol_status.rb
roda-3.50.0 lib/roda/plugins/symbol_status.rb
roda-3.49.0 lib/roda/plugins/symbol_status.rb
roda-3.48.0 lib/roda/plugins/symbol_status.rb
roda-3.47.0 lib/roda/plugins/symbol_status.rb
roda-3.46.0 lib/roda/plugins/symbol_status.rb
roda-3.45.0 lib/roda/plugins/symbol_status.rb
roda-3.44.0 lib/roda/plugins/symbol_status.rb
roda-3.43.1 lib/roda/plugins/symbol_status.rb
roda-3.43.0 lib/roda/plugins/symbol_status.rb
roda-3.42.0 lib/roda/plugins/symbol_status.rb
roda-3.41.0 lib/roda/plugins/symbol_status.rb
roda-3.40.0 lib/roda/plugins/symbol_status.rb
roda-3.39.0 lib/roda/plugins/symbol_status.rb
roda-3.38.0 lib/roda/plugins/symbol_status.rb
roda-3.37.0 lib/roda/plugins/symbol_status.rb