Class: ConfigCat::User
- Inherits:
-
Object
- Object
- ConfigCat::User
- Defined in:
- lib/configcat/user.rb
Overview
The user object for variation evaluation
Constant Summary collapse
- PREDEFINED =
["Identifier", "Email", "Country"]
Instance Attribute Summary collapse
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
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.
- #to_s ⇒ Object
Constructor Details
#initialize(identifier, email: nil, country: nil, custom: nil) ⇒ User
Returns a new instance of User.
8 9 10 11 12 |
# File 'lib/configcat/user.rb', line 8 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 Attribute Details
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
6 7 8 |
# File 'lib/configcat/user.rb', line 6 def identifier @identifier end |
Instance Method Details
#get_attribute(attribute) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/configcat/user.rb', line 18 def get_attribute(attribute) attribute = attribute.to_s return @data[attribute] if PREDEFINED.include?(attribute) return @custom[attribute] if @custom return nil end |
#get_identifier ⇒ Object
14 15 16 |
# File 'lib/configcat/user.rb', line 14 def get_identifier return @identifier end |
#to_s ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/configcat/user.rb', line 25 def to_s dump = { 'Identifier': @identifier, 'Email': @data['Email'], 'Country': @data['Country'], 'Custom': @custom, } return dump.to_json end |