Class: Operations::FeatureFlagsClient

Inherits:
ApplicationRecord show all
Includes:
TokenAuthenticatable
Defined in:
app/models/operations/feature_flags_client.rb

Constant Summary collapse

DEFAULT_UNLEASH_API_VERSION =
1

Constants inherited from ApplicationRecord

ApplicationRecord::MAX_PLUCK

Constants included from ResetOnUnionError

ResetOnUnionError::MAX_RESET_PERIOD

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationRecord

cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order

Methods included from SensitiveSerializableHash

#serializable_hash

Instance Attribute Details

#unleash_app_nameObject

Returns the value of attribute unleash_app_name.



18
19
20
# File 'app/models/operations/feature_flags_client.rb', line 18

def unleash_app_name
  @unleash_app_name
end

Class Method Details

.find_for_project_and_token(project_id, token) ⇒ Object



22
23
24
25
26
27
# File 'app/models/operations/feature_flags_client.rb', line 22

def self.find_for_project_and_token(project_id, token)
  return unless project_id
  return unless token

  where(project_id: project_id).find_by_token(token)
end

.update_last_feature_flag_updated_at!(project) ⇒ Object



29
30
31
# File 'app/models/operations/feature_flags_client.rb', line 29

def self.update_last_feature_flag_updated_at!(project)
  where(project: project).update_all(last_feature_flag_updated_at: Time.current)
end

Instance Method Details

#unleash_api_cache_keyObject



43
44
45
46
47
# File 'app/models/operations/feature_flags_client.rb', line 43

def unleash_api_cache_key
  "api_version:#{unleash_api_version}:" \
    "app_name:#{unleash_app_name}:" \
    "updated_at:#{last_feature_flag_updated_at.to_i}"
end

#unleash_api_featuresObject



37
38
39
40
41
# File 'app/models/operations/feature_flags_client.rb', line 37

def unleash_api_features
  return [] unless unleash_app_name.present?

  Operations::FeatureFlag.for_unleash_client(project, unleash_app_name)
end

#unleash_api_versionObject



33
34
35
# File 'app/models/operations/feature_flags_client.rb', line 33

def unleash_api_version
  DEFAULT_UNLEASH_API_VERSION
end