Class: Rox::Core::BUID
- Inherits:
-
Object
- Object
- Rox::Core::BUID
- Defined in:
- lib/rox/core/client/buid.rb
Constant Summary collapse
- BUID_GENERATORS =
[ PropertyType::PLATFORM, PropertyType::APP_KEY, PropertyType::LIB_VERSION, PropertyType::API_VERSION, PropertyType::CUSTOM_PROPERTIES, PropertyType::FEATURE_FLAGS, PropertyType::REMOTE_VARIABLES ].freeze
Instance Method Summary collapse
-
#initialize(sdk_settings, device_properties, flag_repository, custom_property_repository) ⇒ BUID
constructor
A new instance of BUID.
- #query_string_parts ⇒ Object
- #serialize_custom_properties ⇒ Object
- #serialize_feature_flags ⇒ Object
- #to_s ⇒ Object
- #value ⇒ Object
Constructor Details
#initialize(sdk_settings, device_properties, flag_repository, custom_property_repository) ⇒ BUID
Returns a new instance of BUID.
18 19 20 21 22 23 24 |
# File 'lib/rox/core/client/buid.rb', line 18 def initialize(sdk_settings, device_properties, flag_repository, custom_property_repository) @sdk_settings = sdk_settings @device_properties = device_properties @flag_repository = flag_repository @custom_property_repository = custom_property_repository @buid = nil end |
Instance Method Details
#query_string_parts ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/rox/core/client/buid.rb', line 41 def query_string_parts generators = BUID::BUID_GENERATORS.map {|pt, _| pt.name} { PropertyType::BUID.name => value, PropertyType::BUID_GENERATORS_LIST.name => generators.join(','), PropertyType::FEATURE_FLAGS.name => serialize_feature_flags, PropertyType::REMOTE_VARIABLES.name => '[]', PropertyType::CUSTOM_PROPERTIES.name => serialize_custom_properties, } end |
#serialize_custom_properties ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/rox/core/client/buid.rb', line 65 def serialize_custom_properties properties = [] @custom_property_repository.all_custom_properties.each do |p| properties << { name: p.name, type: p.type.type, externalType: p.type.external_type } end JSON.dump(properties) end |
#serialize_feature_flags ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/rox/core/client/buid.rb', line 53 def serialize_feature_flags flags = [] @flag_repository.all_flags.each do |f| flags << { name: f.name, defaultValue: f.default_value, options: f. } end JSON.dump(flags) end |
#to_s ⇒ Object
77 78 79 |
# File 'lib/rox/core/client/buid.rb', line 77 def to_s @buid end |
#value ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rox/core/client/buid.rb', line 26 def value properties = @device_properties.all_properties values = [] BUID::BUID_GENERATORS.each do |pt, _| values << properties[pt.name] if properties.include?(pt.name) end values << serialize_feature_flags values << serialize_custom_properties hash = Digest::MD5.hexdigest(values.join('|')) @buid = hash.upcase end |