Class: EvoleapLicensing::SessionState
- Inherits:
-
Object
- Object
- EvoleapLicensing::SessionState
- Defined in:
- lib/evoleap_licensing/state/session_state.rb
Instance Attribute Summary collapse
-
#auth_token ⇒ Object
Returns the value of attribute auth_token.
-
#component_entitlements ⇒ Object
Returns the value of attribute component_entitlements.
-
#components ⇒ Object
Returns the value of attribute components.
-
#feature_groups ⇒ Object
Returns the value of attribute feature_groups.
-
#features ⇒ Object
Returns the value of attribute features.
-
#session_duration ⇒ Object
Returns the value of attribute session_duration.
-
#session_key ⇒ Object
Returns the value of attribute session_key.
Instance Method Summary collapse
- #active? ⇒ Boolean
- #clear! ⇒ Object
-
#initialize(hash = nil) ⇒ SessionState
constructor
A new instance of SessionState.
- #to_h ⇒ Object
- #update_components_from_response(response) ⇒ Object
- #update_from_extend_response(response) ⇒ Object
- #update_from_session_response(response) ⇒ Object
Constructor Details
#initialize(hash = nil) ⇒ SessionState
Returns a new instance of SessionState.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/evoleap_licensing/state/session_state.rb', line 9 def initialize(hash = nil) hash = (hash || {}).transform_keys(&:to_s) @auth_token = hash["auth_token"] @session_key = hash["session_key"] @session_duration = hash["session_duration"] @features = hash["features"] || [] @feature_groups = hash["feature_groups"] || [] @components = hash["components"] || [] @component_entitlements = hash["component_entitlements"] || [] end |
Instance Attribute Details
#auth_token ⇒ Object
Returns the value of attribute auth_token.
5 6 7 |
# File 'lib/evoleap_licensing/state/session_state.rb', line 5 def auth_token @auth_token end |
#component_entitlements ⇒ Object
Returns the value of attribute component_entitlements.
5 6 7 |
# File 'lib/evoleap_licensing/state/session_state.rb', line 5 def component_entitlements @component_entitlements end |
#components ⇒ Object
Returns the value of attribute components.
5 6 7 |
# File 'lib/evoleap_licensing/state/session_state.rb', line 5 def components @components end |
#feature_groups ⇒ Object
Returns the value of attribute feature_groups.
5 6 7 |
# File 'lib/evoleap_licensing/state/session_state.rb', line 5 def feature_groups @feature_groups end |
#features ⇒ Object
Returns the value of attribute features.
5 6 7 |
# File 'lib/evoleap_licensing/state/session_state.rb', line 5 def features @features end |
#session_duration ⇒ Object
Returns the value of attribute session_duration.
5 6 7 |
# File 'lib/evoleap_licensing/state/session_state.rb', line 5 def session_duration @session_duration end |
#session_key ⇒ Object
Returns the value of attribute session_key.
5 6 7 |
# File 'lib/evoleap_licensing/state/session_state.rb', line 5 def session_key @session_key end |
Instance Method Details
#active? ⇒ Boolean
20 21 22 |
# File 'lib/evoleap_licensing/state/session_state.rb', line 20 def active? !@auth_token.nil? && !@session_key.nil? end |
#clear! ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/evoleap_licensing/state/session_state.rb', line 24 def clear! @auth_token = nil @session_key = nil @session_duration = nil @features = [] @feature_groups = [] @components = [] @component_entitlements = [] end |
#to_h ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/evoleap_licensing/state/session_state.rb', line 56 def to_h { "auth_token" => @auth_token, "session_key" => @session_key, "session_duration" => @session_duration, "features" => @features, "feature_groups" => @feature_groups, "components" => @components, "component_entitlements" => @component_entitlements } end |
#update_components_from_response(response) ⇒ Object
51 52 53 54 |
# File 'lib/evoleap_licensing/state/session_state.rb', line 51 def update_components_from_response(response) @components = response["components"] if response["components"] @component_entitlements = response["component_entitlements"] if response["component_entitlements"] end |
#update_from_extend_response(response) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/evoleap_licensing/state/session_state.rb', line 43 def update_from_extend_response(response) @auth_token = response["token"] if response["token"] @session_duration = response["session_duration"] if response["session_duration"] @features = response["features"] if response["features"] @feature_groups = response["feature_groups"] if response["feature_groups"] update_components_from_response(response) end |
#update_from_session_response(response) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/evoleap_licensing/state/session_state.rb', line 34 def update_from_session_response(response) @auth_token = response["token"] if response["token"] @session_key = response["session_key"] if response["session_key"] @session_duration = response["session_duration"] if response["session_duration"] @features = response["features"] if response["features"] @feature_groups = response["feature_groups"] if response["feature_groups"] update_components_from_response(response) end |