Class: Rage::Cable::Connection
- Inherits:
-
Object
- Object
- Rage::Cable::Connection
- Defined in:
- lib/rage/cable/connection.rb
Class Method Summary collapse
-
.identified_by(*identifiers) ⇒ Object
Mark a key as being a connection identifier index that can then be used to find the specific connection again later.
Instance Method Summary collapse
-
#cookies ⇒ Rage::Cookies
Get the cookie object.
-
#params ⇒ Hash{Symbol=>String,Array,Hash}
Get URL query parameters.
-
#reject_unauthorized_connection ⇒ Object
Reject the WebSocket connection.
- #rejected? ⇒ Boolean
-
#request ⇒ Rage::Request
Get the request object.
-
#session ⇒ Rage::Session
Get the session object.
Class Method Details
.identified_by(*identifiers) ⇒ Object
Mark a key as being a connection identifier index that can then be used to find the specific connection again later. Common identifiers are current_user
and current_account
, but could be anything.
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/rage/cable/connection.rb', line 11 def self.identified_by(*identifiers) identifiers.each do |method_name| define_method(method_name) do @__identified_by_map[method_name] end define_method("#{method_name}=") do |data| @__identified_by_map[method_name] = data end Rage::Cable::Channel.__prepare_id_method(method_name) end end |
Instance Method Details
#cookies ⇒ Rage::Cookies
Get the cookie object. See Rage::Cookies.
54 55 56 |
# File 'lib/rage/cable/connection.rb', line 54 def @__cookies ||= Rage::Cookies.new(@__env, ReadOnlyHash.new) end |
#params ⇒ Hash{Symbol=>String,Array,Hash}
Get URL query parameters.
68 69 70 |
# File 'lib/rage/cable/connection.rb', line 68 def params @__params ||= Iodine::Rack::Utils.parse_nested_query(@__env["QUERY_STRING"]) end |
#reject_unauthorized_connection ⇒ Object
Reject the WebSocket connection.
36 37 38 |
# File 'lib/rage/cable/connection.rb', line 36 def @rejected = true end |
#rejected? ⇒ Boolean
40 41 42 |
# File 'lib/rage/cable/connection.rb', line 40 def rejected? !!@rejected end |
#request ⇒ Rage::Request
Get the request object. See Request.
47 48 49 |
# File 'lib/rage/cable/connection.rb', line 47 def request @__request ||= Rage::Request.new(@__env) end |
#session ⇒ Rage::Session
Get the session object. See Session.
61 62 63 |
# File 'lib/rage/cable/connection.rb', line 61 def session @__session ||= Rage::Session.new() end |