Class: SockJS::Endpoint::MethodMap

Inherits:
Object
  • Object
show all
Defined in:
lib/sockjs/transport.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(map) ⇒ MethodMap

Returns a new instance of MethodMap.



18
19
20
# File 'lib/sockjs/transport.rb', line 18

def initialize(map)
  @method_map = map
end

Instance Attribute Details

#method_mapObject (readonly)

Returns the value of attribute method_map.



21
22
23
# File 'lib/sockjs/transport.rb', line 21

def method_map
  @method_map
end

Instance Method Details

#call(env) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/sockjs/transport.rb', line 23

def call(env)
  app = @method_map.fetch(env["REQUEST_METHOD"])
  app.call(env)
rescue KeyError
  ::SockJS.debug "Method not supported!"
  [405, {"Allow" => methods_map.keys.join(", ") }, []]
end