Class: Operations::FeatureFlag
Constant Summary
Constants included
from Limitable
Limitable::GLOBAL_SCOPE
AtomicInternalId::MissingValueError
ApplicationRecord::MAX_PLUCK
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Referable
#referable_inspect, #reference_link_text, #to_reference_base
Methods included from IidRoutes
#to_param
group_init, #internal_id_read_scope, #internal_id_scope_attrs, #internal_id_scope_usage, project_init, scope_attrs, scope_usage
#run_after_commit, #run_after_commit_or_now
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
#serializable_hash
Class Method Details
.for_unleash_client(project, environment) ⇒ Object
56
57
58
59
60
61
62
|
# File 'app/models/operations/feature_flag.rb', line 56
def for_unleash_client(project, environment)
includes(strategies: [:scopes, :user_list])
.where(project: project)
.merge(Operations::FeatureFlags::Scope.on_environment(environment))
.reorder(:id)
.references(:operations_scopes)
end
|
.link_reference_pattern ⇒ Object
74
75
76
|
# File 'app/models/operations/feature_flag.rb', line 74
def link_reference_pattern
@link_reference_pattern ||= super("feature_flags", %r{(?<feature_flag>\d+)/edit})
end
|
.preload_relations ⇒ Object
52
53
54
|
# File 'app/models/operations/feature_flag.rb', line 52
def preload_relations
preload(strategies: :scopes)
end
|
.reference_pattern ⇒ Object
68
69
70
71
72
|
# File 'app/models/operations/feature_flag.rb', line 68
def reference_pattern
@reference_pattern ||= %r{
#{Regexp.escape(reference_prefix)}(#{::Project.reference_pattern}\/)?(?<feature_flag>\d+)#{Regexp.escape(reference_postfix)}
}x
end
|
.reference_postfix ⇒ Object
78
79
80
|
# File 'app/models/operations/feature_flag.rb', line 78
def reference_postfix
']'
end
|
.reference_prefix ⇒ Object
64
65
66
|
# File 'app/models/operations/feature_flag.rb', line 64
def reference_prefix
'[feature_flag:'
end
|
Instance Method Details
#hook_attrs ⇒ Object
101
102
103
104
105
106
107
108
|
# File 'app/models/operations/feature_flag.rb', line 101
def hook_attrs
{
id: id,
name: name,
description: description,
active: active
}
end
|
90
91
92
93
94
95
96
97
98
99
|
# File 'app/models/operations/feature_flag.rb', line 90
def related_issues(current_user, preload:)
issues = ::Issue
.select('issues.*, operations_feature_flags_issues.id AS link_id')
.joins(:feature_flag_issues)
.where(operations_feature_flags_issues: { feature_flag_id: id })
.order('operations_feature_flags_issues.id ASC')
.includes(preload)
Ability.issues_readable_by_user(issues, current_user)
end
|
#to_reference(from = nil, full: false) ⇒ Object
83
84
85
86
87
88
|
# File 'app/models/operations/feature_flag.rb', line 83
def to_reference(from = nil, full: false)
project
.to_reference_base(from, full: full)
.then { |reference_base| reference_base.present? ? "#{reference_base}/" : nil }
.then { |reference_base| "#{self.class.reference_prefix}#{reference_base}#{iid}#{self.class.reference_postfix}" }
end
|