Class: Unleash::Context
- Inherits:
-
Object
- Object
- Unleash::Context
- Defined in:
- lib/unleash/context.rb
Instance Attribute Summary collapse
-
#properties ⇒ Object
Returns the value of attribute properties.
-
#remote_address ⇒ Object
Returns the value of attribute remote_address.
-
#session_id ⇒ Object
Returns the value of attribute session_id.
-
#user_id ⇒ Object
Returns the value of attribute user_id.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Context
constructor
A new instance of Context.
- #to_s ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Context
Returns a new instance of Context.
6 7 8 9 10 11 12 |
# File 'lib/unleash/context.rb', line 6 def initialize(params = {}) params_is_a_hash = params.is_a?(Hash) self.user_id = params_is_a_hash ? params.fetch(:user_id, '') : '' self.session_id = params_is_a_hash ? params.fetch(:session_id, '') : '' self.remote_address = params_is_a_hash ? params.fetch(:remote_address, '') : '' self.properties = params_is_a_hash && params[:properties].is_a?(Hash) ? params.fetch(:properties, {}) : {} end |
Instance Attribute Details
#properties ⇒ Object
Returns the value of attribute properties.
4 5 6 |
# File 'lib/unleash/context.rb', line 4 def properties @properties end |
#remote_address ⇒ Object
Returns the value of attribute remote_address.
4 5 6 |
# File 'lib/unleash/context.rb', line 4 def remote_address @remote_address end |
#session_id ⇒ Object
Returns the value of attribute session_id.
4 5 6 |
# File 'lib/unleash/context.rb', line 4 def session_id @session_id end |
#user_id ⇒ Object
Returns the value of attribute user_id.
4 5 6 |
# File 'lib/unleash/context.rb', line 4 def user_id @user_id end |
Instance Method Details
#to_s ⇒ Object
14 15 16 |
# File 'lib/unleash/context.rb', line 14 def to_s "<Context: user_id=#{self.user_id},session_id=#{self.session_id},remote_address=#{self.remote_address},properties=#{self.properties}>" end |