Class: ContextModel
- Inherits:
-
Object
- Object
- ContextModel
- Defined in:
- lib/wingify/models/user/context_model.rb
Instance Attribute Summary collapse
-
#bucketing_seed ⇒ Object
Returns the value of attribute bucketing_seed.
-
#custom_variables ⇒ Object
Returns the value of attribute custom_variables.
-
#id ⇒ Object
Returns the value of attribute id.
-
#ip_address ⇒ Object
Returns the value of attribute ip_address.
-
#post_segmentation_variables ⇒ Object
Returns the value of attribute post_segmentation_variables.
-
#session_id ⇒ Object
Returns the value of attribute session_id.
-
#user_agent ⇒ Object
Returns the value of attribute user_agent.
-
#uuid ⇒ Object
Returns the value of attribute uuid.
-
#variation_targeting_variables ⇒ Object
Returns the value of attribute variation_targeting_variables.
-
#vwo ⇒ Object
Returns the value of attribute vwo.
Instance Method Summary collapse
- #get_bucketing_seed ⇒ Object
- #get_custom_variables ⇒ Object
- #get_id ⇒ Object
- #get_ip_address ⇒ Object
- #get_post_segmentation_variables ⇒ Object
- #get_session_id ⇒ Object
- #get_user_agent ⇒ Object
- #get_uuid ⇒ Object
- #get_variation_targeting_variables ⇒ Object
- #get_vwo ⇒ Object
-
#initialize(id = nil, user_agent = nil, ip_address = nil, custom_variables = {}, variation_targeting_variables = {}, post_segmentation_variables = {}, vwo = nil, session_id = nil, uuid = nil, bucketing_seed = nil) ⇒ ContextModel
constructor
A new instance of ContextModel.
-
#model_from_dictionary(context) ⇒ Object
Creates a model instance from a hash (dictionary).
- #set_bucketing_seed(bucketing_seed) ⇒ Object
- #set_custom_variables(custom_variables) ⇒ Object
- #set_id(id) ⇒ Object
- #set_ip_address(ip_address) ⇒ Object
- #set_post_segmentation_variables(post_segmentation_variables) ⇒ Object
- #set_session_id(session_id) ⇒ Object
- #set_user_agent(user_agent) ⇒ Object
- #set_uuid(uuid) ⇒ Object
- #set_variation_targeting_variables(variation_targeting_variables) ⇒ Object
- #set_vwo(vwo) ⇒ Object
Constructor Details
#initialize(id = nil, user_agent = nil, ip_address = nil, custom_variables = {}, variation_targeting_variables = {}, post_segmentation_variables = {}, vwo = nil, session_id = nil, uuid = nil, bucketing_seed = nil) ⇒ ContextModel
Returns a new instance of ContextModel.
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/wingify/models/user/context_model.rb', line 22 def initialize(id = nil, user_agent = nil, ip_address = nil, custom_variables = {}, variation_targeting_variables = {}, post_segmentation_variables = {}, vwo = nil, session_id = nil, uuid = nil, bucketing_seed = nil) @id = id @user_agent = user_agent @ip_address = ip_address @custom_variables = custom_variables || {} @variation_targeting_variables = variation_targeting_variables || {} @post_segmentation_variables = post_segmentation_variables || {} @vwo = vwo @session_id = session_id @uuid = uuid @bucketing_seed = bucketing_seed end |
Instance Attribute Details
#bucketing_seed ⇒ Object
Returns the value of attribute bucketing_seed.
20 21 22 |
# File 'lib/wingify/models/user/context_model.rb', line 20 def bucketing_seed @bucketing_seed end |
#custom_variables ⇒ Object
Returns the value of attribute custom_variables.
20 21 22 |
# File 'lib/wingify/models/user/context_model.rb', line 20 def custom_variables @custom_variables end |
#id ⇒ Object
Returns the value of attribute id.
20 21 22 |
# File 'lib/wingify/models/user/context_model.rb', line 20 def id @id end |
#ip_address ⇒ Object
Returns the value of attribute ip_address.
20 21 22 |
# File 'lib/wingify/models/user/context_model.rb', line 20 def ip_address @ip_address end |
#post_segmentation_variables ⇒ Object
Returns the value of attribute post_segmentation_variables.
20 21 22 |
# File 'lib/wingify/models/user/context_model.rb', line 20 def post_segmentation_variables @post_segmentation_variables end |
#session_id ⇒ Object
Returns the value of attribute session_id.
20 21 22 |
# File 'lib/wingify/models/user/context_model.rb', line 20 def session_id @session_id end |
#user_agent ⇒ Object
Returns the value of attribute user_agent.
20 21 22 |
# File 'lib/wingify/models/user/context_model.rb', line 20 def user_agent @user_agent end |
#uuid ⇒ Object
Returns the value of attribute uuid.
20 21 22 |
# File 'lib/wingify/models/user/context_model.rb', line 20 def uuid @uuid end |
#variation_targeting_variables ⇒ Object
Returns the value of attribute variation_targeting_variables.
20 21 22 |
# File 'lib/wingify/models/user/context_model.rb', line 20 def variation_targeting_variables @variation_targeting_variables end |
#vwo ⇒ Object
Returns the value of attribute vwo.
20 21 22 |
# File 'lib/wingify/models/user/context_model.rb', line 20 def vwo @vwo end |
Instance Method Details
#get_bucketing_seed ⇒ Object
147 148 149 |
# File 'lib/wingify/models/user/context_model.rb', line 147 def get_bucketing_seed @bucketing_seed end |
#get_custom_variables ⇒ Object
99 100 101 |
# File 'lib/wingify/models/user/context_model.rb', line 99 def get_custom_variables @custom_variables end |
#get_id ⇒ Object
75 76 77 |
# File 'lib/wingify/models/user/context_model.rb', line 75 def get_id @id end |
#get_ip_address ⇒ Object
91 92 93 |
# File 'lib/wingify/models/user/context_model.rb', line 91 def get_ip_address @ip_address end |
#get_post_segmentation_variables ⇒ Object
115 116 117 |
# File 'lib/wingify/models/user/context_model.rb', line 115 def get_post_segmentation_variables @post_segmentation_variables end |
#get_session_id ⇒ Object
131 132 133 |
# File 'lib/wingify/models/user/context_model.rb', line 131 def get_session_id @session_id end |
#get_user_agent ⇒ Object
83 84 85 |
# File 'lib/wingify/models/user/context_model.rb', line 83 def get_user_agent @user_agent end |
#get_uuid ⇒ Object
139 140 141 |
# File 'lib/wingify/models/user/context_model.rb', line 139 def get_uuid @uuid end |
#get_variation_targeting_variables ⇒ Object
107 108 109 |
# File 'lib/wingify/models/user/context_model.rb', line 107 def get_variation_targeting_variables @variation_targeting_variables end |
#get_vwo ⇒ Object
123 124 125 |
# File 'lib/wingify/models/user/context_model.rb', line 123 def get_vwo @vwo end |
#model_from_dictionary(context) ⇒ Object
Creates a model instance from a hash (dictionary)
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/wingify/models/user/context_model.rb', line 36 def model_from_dictionary(context) if context.key?(:customVariables) && !context[:customVariables].is_a?(Hash) raise TypeError, 'Invalid context, customVariables should be a hash' end if context.key?(:userAgent) && !context[:userAgent].is_a?(String) raise TypeError, 'Invalid context, userAgent should be a string' end if context.key?(:ipAddress) && !context[:ipAddress].is_a?(String) raise TypeError, 'Invalid context, ipAddress should be a string' end @id = context[:id] @user_agent = context[:userAgent] @ip_address = context[:ipAddress] @custom_variables = context[:customVariables] if context.key?(:customVariables) @variation_targeting_variables = context[:variationTargetingVariables] if context.key?(:variationTargetingVariables) @post_segmentation_variables = context[:postSegmentationVariables] if context.key?(:postSegmentationVariables) @vwo = ContextVWOModel.new.model_from_dictionary(context[:_vwo]) if context.key?(:_vwo) @bucketing_seed = context[:bucketingSeed].to_s if context.key?(:bucketingSeed) # check if sessionId is present in context and should be non null and non empty if context.key?(:sessionId) && !context[:sessionId].nil? && !context[:sessionId].to_s.empty? @session_id = context[:sessionId].to_i else @session_id = Time.now.to_i end # check if uuid is present in context and should be non null and non empty string if context.key?(:uuid) && context[:uuid].is_a?(String) && !context[:uuid].empty? @uuid = context[:uuid] else @uuid = UUIDUtil.get_uuid(id.to_s, SettingsService.instance.account_id.to_s) end self end |
#set_bucketing_seed(bucketing_seed) ⇒ Object
151 152 153 |
# File 'lib/wingify/models/user/context_model.rb', line 151 def set_bucketing_seed(bucketing_seed) @bucketing_seed = bucketing_seed end |
#set_custom_variables(custom_variables) ⇒ Object
103 104 105 |
# File 'lib/wingify/models/user/context_model.rb', line 103 def set_custom_variables(custom_variables) @custom_variables = custom_variables end |
#set_id(id) ⇒ Object
79 80 81 |
# File 'lib/wingify/models/user/context_model.rb', line 79 def set_id(id) @id = id end |
#set_ip_address(ip_address) ⇒ Object
95 96 97 |
# File 'lib/wingify/models/user/context_model.rb', line 95 def set_ip_address(ip_address) @ip_address = ip_address end |
#set_post_segmentation_variables(post_segmentation_variables) ⇒ Object
119 120 121 |
# File 'lib/wingify/models/user/context_model.rb', line 119 def set_post_segmentation_variables(post_segmentation_variables) @post_segmentation_variables = post_segmentation_variables end |
#set_session_id(session_id) ⇒ Object
135 136 137 |
# File 'lib/wingify/models/user/context_model.rb', line 135 def set_session_id(session_id) @session_id = session_id end |
#set_user_agent(user_agent) ⇒ Object
87 88 89 |
# File 'lib/wingify/models/user/context_model.rb', line 87 def set_user_agent(user_agent) @user_agent = user_agent end |
#set_uuid(uuid) ⇒ Object
143 144 145 |
# File 'lib/wingify/models/user/context_model.rb', line 143 def set_uuid(uuid) @uuid = uuid end |
#set_variation_targeting_variables(variation_targeting_variables) ⇒ Object
111 112 113 |
# File 'lib/wingify/models/user/context_model.rb', line 111 def set_variation_targeting_variables(variation_targeting_variables) @variation_targeting_variables = variation_targeting_variables end |
#set_vwo(vwo) ⇒ Object
127 128 129 |
# File 'lib/wingify/models/user/context_model.rb', line 127 def set_vwo(vwo) @vwo = vwo end |