Class: Wampproto::Message::Hello
- Defined in:
- lib/wampproto/message/hello.rb
Overview
Wamp Hello message
Instance Attribute Summary collapse
-
#details ⇒ Object
readonly
Returns the value of attribute details.
-
#realm ⇒ Object
readonly
Returns the value of attribute realm.
Class Method Summary collapse
Instance Method Summary collapse
- #authextra ⇒ Object
- #authid ⇒ Object
- #authmethods ⇒ Object
-
#initialize(realm, details = {}) ⇒ Hello
constructor
A new instance of Hello.
- #marshal ⇒ Object
- #parse_details(hsh = {}) ⇒ Object
- #roles ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(realm, details = {}) ⇒ Hello
Returns a new instance of Hello.
9 10 11 12 13 |
# File 'lib/wampproto/message/hello.rb', line 9 def initialize(realm, details = {}) super() @realm = Validate.string!("Realm", realm) @details = default_details.merge(parse_details(Validate.hash!("Details", details))).merge(additional_details) end |
Instance Attribute Details
#details ⇒ Object (readonly)
Returns the value of attribute details.
7 8 9 |
# File 'lib/wampproto/message/hello.rb', line 7 def details @details end |
#realm ⇒ Object (readonly)
Returns the value of attribute realm.
7 8 9 |
# File 'lib/wampproto/message/hello.rb', line 7 def realm @realm end |
Class Method Details
.parse(wamp_message) ⇒ Object
28 29 30 31 |
# File 'lib/wampproto/message/hello.rb', line 28 def self.parse() _type, realm, details = new(realm, details) end |
Instance Method Details
#authextra ⇒ Object
45 46 47 |
# File 'lib/wampproto/message/hello.rb', line 45 def authextra @authextra ||= details.fetch(:authextra, {}) end |
#authid ⇒ Object
37 38 39 |
# File 'lib/wampproto/message/hello.rb', line 37 def authid @authid ||= details[:authid] end |
#authmethods ⇒ Object
41 42 43 |
# File 'lib/wampproto/message/hello.rb', line 41 def authmethods @authmethods ||= details.fetch(:authmethods, []) end |
#marshal ⇒ Object
15 16 17 |
# File 'lib/wampproto/message/hello.rb', line 15 def marshal [Type::HELLO, @realm, @details] end |
#parse_details(hsh = {}) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/wampproto/message/hello.rb', line 19 def parse_details(hsh = {}) details = {} details[:roles] = hsh.fetch(:roles, default_roles) details[:authid] = hsh.fetch(:authid, nil) details[:authmethods] = [*hsh.fetch(:authmethods, "anonymous")] details[:authextra] = Validate.hash!("AuthExtra", hsh.fetch(:authextra)) if hsh[:authextra] details end |
#roles ⇒ Object
33 34 35 |
# File 'lib/wampproto/message/hello.rb', line 33 def roles @roles ||= details.fetch(:roles, {}) end |