Class: Rox::Core::PropertyFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/rox/core/properties/property_factory.rb

Overview

Consolidates creation of all the internal properties

Instance Method Summary collapse

Constructor Details

#initialize(server_properties) ⇒ PropertyFactory

Returns a new instance of PropertyFactory.



14
15
16
# File 'lib/rox/core/properties/property_factory.rb', line 14

def initialize(server_properties)
  @server_properties = server_properties
end

Instance Method Details

#all_propertiesObject

rubocop:disable Metrics/MethodLength



128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/rox/core/properties/property_factory.rb', line 128

def all_properties
  [
    platform,
    app_release,
    distinct_id,
    internal_real_platform,
    internal_custom_platform,
    internal_app_key,
    internal_distinct_id,
    internal_lib_version,
    internal_api_version,
    internal_datetime
  ]
end

#app_releaseObject



29
30
31
32
33
34
35
36
37
38
# File 'lib/rox/core/properties/property_factory.rb', line 29

def app_release
  property = Rox::Core::PropertyType::APP_RELEASE
  type = Rox::Core::CustomPropertyType::SEMVER

  Rox::Core::DeviceProperty.new(
    property.name,
    type,
    @server_properties.get(property)
  )
end

#distinct_idObject



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/rox/core/properties/property_factory.rb', line 40

def distinct_id
  property = Rox::Core::PropertyType::DISTINCT_ID
  type = Rox::Core::CustomPropertyType::STRING

  Rox::Core::DeviceProperty.new(
    property.name,
    type
  ) do |_|
    SecureRandom.uuid
  end
end

#internal_api_versionObject



105
106
107
108
109
110
111
112
113
114
# File 'lib/rox/core/properties/property_factory.rb', line 105

def internal_api_version
  property = Rox::Core::PropertyType::API_VERSION
  type = Rox::Core::CustomPropertyType::SEMVER

  Rox::Core::DeviceProperty.new(
    'internal.api_version',
    type,
    property
  )
end

#internal_app_keyObject



74
75
76
77
78
79
80
81
82
# File 'lib/rox/core/properties/property_factory.rb', line 74

def internal_app_key
  type = Rox::Core::CustomPropertyType::STRING

  Rox::Core::DeviceProperty.new(
    'internal.appKey',
    type,
    @server_properties.rollout_key
  )
end

#internal_custom_platformObject



63
64
65
66
67
68
69
70
71
72
# File 'lib/rox/core/properties/property_factory.rb', line 63

def internal_custom_platform
  property = Rox::Core::PropertyType::PLATFORM
  type = Rox::Core::CustomPropertyType::STRING

  Rox::Core::DeviceProperty.new(
    'internal.customPlatform',
    type,
    @server_properties.get(property)
  )
end

#internal_datetimeObject



116
117
118
119
120
121
122
123
124
125
# File 'lib/rox/core/properties/property_factory.rb', line 116

def internal_datetime
  type = Rox::Core::CustomPropertyType::DATETIME

  Rox::Core::DeviceProperty.new(
    "now",
    type
  ) do
    Time.now
  end
end

#internal_distinct_idObject



84
85
86
87
88
89
90
91
92
93
# File 'lib/rox/core/properties/property_factory.rb', line 84

def internal_distinct_id
  type = Rox::Core::CustomPropertyType::STRING

  Rox::Core::DeviceProperty.new(
    "internal.#{Rox::Core::PropertyType::DISTINCT_ID.name}",
    type
  ) do
    SecureRandom.uuid
  end
end

#internal_lib_versionObject



95
96
97
98
99
100
101
102
103
# File 'lib/rox/core/properties/property_factory.rb', line 95

def internal_lib_version
  type = Rox::Core::CustomPropertyType::SEMVER

  Rox::Core::DeviceProperty.new(
    'internal.lib_version',
    type,
    @server_properties.lib_version
  )
end

#internal_real_platformObject



52
53
54
55
56
57
58
59
60
61
# File 'lib/rox/core/properties/property_factory.rb', line 52

def internal_real_platform
  property = Rox::Core::PropertyType::PLATFORM
  type = Rox::Core::CustomPropertyType::STRING

  Rox::Core::DeviceProperty.new(
    'internal.realPlatform',
    type,
    @server_properties.get(property)
  )
end

#platformObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/rox/core/properties/property_factory.rb', line 18

def platform
  property = Rox::Core::PropertyType::PLATFORM
  type = Rox::Core::CustomPropertyType::STRING

  Rox::Core::DeviceProperty.new(
    property.name,
    type,
    @server_properties.get(property)
  )
end