Class: Reactive::Mvc::Controller::MethodNotAllowed

Inherits:
Error
  • Object
show all
Defined in:
lib/reactive-mvc/controller/base.rb

Overview

:nodoc:

Direct Known Subclasses

NotImplemented

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*allowed_methods) ⇒ MethodNotAllowed

Returns a new instance of MethodNotAllowed.



9
10
11
12
# File 'lib/reactive-mvc/controller/base.rb', line 9

def initialize(*allowed_methods)
  super("Only #{allowed_methods.to_sentence} requests are allowed.")
  @allowed_methods = allowed_methods
end

Instance Attribute Details

#allowed_methodsObject (readonly)

Returns the value of attribute allowed_methods.



7
8
9
# File 'lib/reactive-mvc/controller/base.rb', line 7

def allowed_methods
  @allowed_methods
end

Instance Method Details

#allowed_methods_headerObject



14
15
16
# File 'lib/reactive-mvc/controller/base.rb', line 14

def allowed_methods_header
  allowed_methods.map { |method_symbol| method_symbol.to_s.upcase } * ', '
end

#handle_response!(response) ⇒ Object



18
19
20
# File 'lib/reactive-mvc/controller/base.rb', line 18

def handle_response!(response)
  response.headers['Allow'] ||= allowed_methods_header
end