Class: Rox::Core::BUID

Inherits:
Object
  • Object
show all
Defined in:
lib/rox/core/client/buid.rb

Constant Summary collapse

BUID_GENERATORS =
[
  PropertyType::PLATFORM,
  PropertyType::APP_KEY,
  PropertyType::LIB_VERSION,
  PropertyType::API_VERSION
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(sdk_settings, device_properties, _flag_repository, _custom_property_repository) ⇒ BUID

Returns a new instance of BUID.



15
16
17
18
19
# File 'lib/rox/core/client/buid.rb', line 15

def initialize(sdk_settings, device_properties, _flag_repository, _custom_property_repository)
  @sdk_settings = sdk_settings
  @device_properties = device_properties
  @buid = nil
end

Instance Method Details

#query_string_partsObject



33
34
35
36
37
38
39
40
# File 'lib/rox/core/client/buid.rb', line 33

def query_string_parts
  generators = BUID::BUID_GENERATORS.map { |pt, _| pt.name }

  {
    PropertyType::BUID.name => value,
    PropertyType::BUID_GENERATORS_LIST.name => generators.join(',')
  }
end

#to_sObject



42
43
44
# File 'lib/rox/core/client/buid.rb', line 42

def to_s
  @buid
end

#valueObject



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rox/core/client/buid.rb', line 21

def value
  properties = @device_properties.all_properties
  values = []
  BUID::BUID_GENERATORS.each do |pt, _|
    values << properties[pt.name] if properties.include?(pt.name)
  end

  hash = Digest::MD5.hexdigest(values.join('|'))

  @buid = hash.upcase
end