Class: Legion::Context::SessionContext
- Inherits:
-
Object
- Object
- Legion::Context::SessionContext
- Defined in:
- lib/legion/context.rb
Instance Attribute Summary collapse
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#session_id ⇒ Object
readonly
Returns the value of attribute session_id.
-
#started_at ⇒ Object
readonly
Returns the value of attribute started_at.
-
#user_id ⇒ Object
readonly
Returns the value of attribute user_id.
Instance Method Summary collapse
-
#initialize(session_id: nil, user_id: nil, metadata: {}) ⇒ SessionContext
constructor
A new instance of SessionContext.
- #to_h ⇒ Object
Constructor Details
#initialize(session_id: nil, user_id: nil, metadata: {}) ⇒ SessionContext
Returns a new instance of SessionContext.
10 11 12 13 14 15 |
# File 'lib/legion/context.rb', line 10 def initialize(session_id: nil, user_id: nil, metadata: {}) @session_id = session_id || SecureRandom.uuid @user_id = user_id @started_at = Time.now @metadata = end |
Instance Attribute Details
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
8 9 10 |
# File 'lib/legion/context.rb', line 8 def @metadata end |
#session_id ⇒ Object (readonly)
Returns the value of attribute session_id.
8 9 10 |
# File 'lib/legion/context.rb', line 8 def session_id @session_id end |
#started_at ⇒ Object (readonly)
Returns the value of attribute started_at.
8 9 10 |
# File 'lib/legion/context.rb', line 8 def started_at @started_at end |
#user_id ⇒ Object (readonly)
Returns the value of attribute user_id.
8 9 10 |
# File 'lib/legion/context.rb', line 8 def user_id @user_id end |
Instance Method Details
#to_h ⇒ Object
17 18 19 |
# File 'lib/legion/context.rb', line 17 def to_h { session_id: session_id, user_id: user_id, started_at: started_at.iso8601 } end |