Module: SockJS::Endpoint::ClassMethods
- Included in:
- SockJS::Endpoint
- Defined in:
- lib/sockjs/transport.rb
Instance Attribute Summary collapse
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
Instance Method Summary collapse
- #add_route(route_set, connection, options) ⇒ Object
- #add_routes(route_set, connection, options) ⇒ Object
- #endpoints ⇒ Object
- #register(method, prefix) ⇒ Object
- #route_conditions ⇒ Object
- #routing_prefix ⇒ Object
Instance Attribute Details
#method ⇒ Object (readonly)
Returns the value of attribute method.
99 100 101 |
# File 'lib/sockjs/transport.rb', line 99 def method @method end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
99 100 101 |
# File 'lib/sockjs/transport.rb', line 99 def prefix @prefix end |
Instance Method Details
#add_route(route_set, connection, options) ⇒ Object
85 86 87 88 |
# File 'lib/sockjs/transport.rb', line 85 def add_route(route_set, connection, ) #SockJS.debug "Adding route for #{self} on #{route_conditions.inspect}" route_set.add_route(self.new(connection, ), route_conditions, {}) end |
#add_routes(route_set, connection, options) ⇒ Object
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/sockjs/transport.rb', line 58 def add_routes(route_set, connection, ) method_catching = Hash.new{|h,k| h[k] = []} endpoints.each do |endpoint_class| endpoint_class.add_route(route_set, connection, ) method_catching[endpoint_class.routing_prefix] << endpoint_class.method end method_catching.each_pair do |prefix, methods| route_set.add_route(MethodNotSupportedApp.new(methods), {:path_info => prefix}, {}) end end |
#endpoints ⇒ Object
90 91 92 |
# File 'lib/sockjs/transport.rb', line 90 def endpoints @endpoints ||= [] end |
#register(method, prefix) ⇒ Object
94 95 96 97 98 |
# File 'lib/sockjs/transport.rb', line 94 def register(method, prefix) @prefix = prefix @method = method Endpoint.endpoints << self end |
#route_conditions ⇒ Object
78 79 80 81 82 83 |
# File 'lib/sockjs/transport.rb', line 78 def route_conditions { :request_method => self.method, :path_info => self.routing_prefix } end |
#routing_prefix ⇒ Object
69 70 71 72 73 74 75 76 |
# File 'lib/sockjs/transport.rb', line 69 def routing_prefix case prefix when String "/" + prefix when Regexp prefix end end |