Module: Roda::RodaPlugins::StatusHandler::ClassMethods

Defined in:
lib/roda/plugins/status_handler.rb

Instance Method Summary collapse

Instance Method Details

#freezeObject

Freeze the hash of status handlers so that there can be no thread safety issues at runtime.



39
40
41
42
# File 'lib/roda/plugins/status_handler.rb', line 39

def freeze
  opts[:status_handler].freeze
  super
end

#status_handler(code, &block) ⇒ Object

Install the given block as a status handler for the given HTTP response code.



32
33
34
35
36
# File 'lib/roda/plugins/status_handler.rb', line 32

def status_handler(code, &block)
  # For backwards compatibility, pass request argument if block accepts argument
  arity = block.arity == 0 ? 0 : 1
  opts[:status_handler][code] = [define_roda_method(:"_roda_status_handler_#{code}", arity, &block), arity]
end