Class: ConfigCat::User
- Inherits:
-
Object
- Object
- ConfigCat::User
- Defined in:
- lib/configcat/user.rb
Constant Summary collapse
- PREDEFINED =
The user object for variation evaluation
["Identifier", "Email", "Country"]
Instance Method Summary collapse
- #get_attribute(attribute) ⇒ Object
- #get_identifier ⇒ Object
-
#initialize(identifier, email: nil, country: nil, custom: nil) ⇒ User
constructor
A new instance of User.
Constructor Details
#initialize(identifier, email: nil, country: nil, custom: nil) ⇒ User
Returns a new instance of User.
10 11 12 13 14 |
# File 'lib/configcat/user.rb', line 10 def initialize(identifier, email: nil, country: nil, custom: nil) @__identifier = (!identifier.equal?(nil)) ? identifier : "" @__data = {"Identifier" => identifier, "Email" => email, "Country" => country} @__custom = custom end |
Instance Method Details
#get_attribute(attribute) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/configcat/user.rb', line 20 def get_attribute(attribute) attribute = attribute.to_s if PREDEFINED.include?(attribute) return @__data[attribute] end if !@__custom.equal?(nil) @__custom.each do |customField, customValue| if customField.to_s == attribute return customValue end end end return nil end |
#get_identifier ⇒ Object
16 17 18 |
# File 'lib/configcat/user.rb', line 16 def get_identifier() return @__identifier end |