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.
58 59 60 |
# File 'lib/rage/cable/connection.rb', line 58 def ||= Rage::Cookies.new(@__env, ReadOnlyHash.new) end |
#params ⇒ Hash{Symbol=>String,Array,Hash}
Get URL query parameters.
72 73 74 |
# File 'lib/rage/cable/connection.rb', line 72 def params @__params ||= Iodine::Rack::Utils.parse_nested_query(@__env["QUERY_STRING"]) end |
#reject_unauthorized_connection ⇒ Object
Reject the WebSocket connection.
40 41 42 |
# File 'lib/rage/cable/connection.rb', line 40 def @rejected = true end |
#rejected? ⇒ Boolean
44 45 46 |
# File 'lib/rage/cable/connection.rb', line 44 def rejected? !!@rejected end |
#request ⇒ Rage::Request
Get the request object. See Request.
51 52 53 |
# File 'lib/rage/cable/connection.rb', line 51 def request @__request ||= Rage::Request.new(@__env) end |
#session ⇒ Rage::Session
Get the session object. See Session.
65 66 67 |
# File 'lib/rage/cable/connection.rb', line 65 def session @__session ||= Rage::Session.new() end |