Class: AmplitudeAPI::Identification
- Inherits:
-
Object
- Object
- AmplitudeAPI::Identification
- Defined in:
- lib/amplitude_api/identification.rb
Overview
AmplitudeAPI::Identification
Instance Attribute Summary collapse
-
#device_id ⇒ String
The device_id to be sent to Amplitude.
-
#user_id ⇒ Object
Returns the value of attribute user_id.
-
#user_properties ⇒ String
The user_properties to be attached to the Amplitude Identify.
Instance Method Summary collapse
-
#==(other) ⇒ true, false
Compares +to_hash+ for equality.
-
#initialize(user_id: "", device_id: nil, user_properties: {}) ⇒ Identification
constructor
Create a new Identification.
-
#to_hash ⇒ Hash
Used for serialization and comparison.
Constructor Details
#initialize(user_id: "", device_id: nil, user_properties: {}) ⇒ Identification
Create a new Identification
21 22 23 24 25 |
# File 'lib/amplitude_api/identification.rb', line 21 def initialize(user_id: "", device_id: nil, user_properties: {}) self.user_id = user_id self.device_id = device_id if device_id self.user_properties = user_properties end |
Instance Attribute Details
#device_id ⇒ String
Returns the device_id to be sent to Amplitude.
11 12 13 |
# File 'lib/amplitude_api/identification.rb', line 11 def device_id @device_id end |
#user_id ⇒ Object
Returns the value of attribute user_id.
8 9 10 |
# File 'lib/amplitude_api/identification.rb', line 8 def user_id @user_id end |
#user_properties ⇒ String
Returns the user_properties to be attached to the Amplitude Identify.
14 15 16 |
# File 'lib/amplitude_api/identification.rb', line 14 def user_properties @user_properties end |
Instance Method Details
#==(other) ⇒ true, false
Compares +to_hash+ for equality
49 50 51 52 53 54 55 |
# File 'lib/amplitude_api/identification.rb', line 49 def ==(other) if other.respond_to?(:to_hash) to_hash == other.to_hash else false end end |
#to_hash ⇒ Hash
Used for serialization and comparison
39 40 41 42 43 44 |
# File 'lib/amplitude_api/identification.rb', line 39 def to_hash { user_id: user_id, user_properties: user_properties }.tap { |hsh| hsh[:device_id] = device_id if device_id } end |