Class: Operations::FeatureFlag
Constant Summary
Constants included
from Limitable
Limitable::GLOBAL_SCOPE
AtomicInternalId::MissingValueError
ApplicationRecord::MAX_PLUCK
HasCheckConstraints::NOT_NULL_CHECK_PATTERN
ResetOnColumnErrors::MAX_RESET_PERIOD
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Referable
#referable_inspect, #reference_link_text, #to_reference_base
Methods included from Limitable
#exceeds_limits?
Methods included from IidRoutes
#to_param
group_init, #internal_id_read_scope, #internal_id_scope_attrs, #internal_id_scope_usage, namespace_init, 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, nullable_column?, 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
#reset_on_union_error, #reset_on_unknown_attribute_error
#serializable_hash
Class Method Details
.for_unleash_client(project, environment) ⇒ Object
62
63
64
65
66
67
68
|
# File 'app/models/operations/feature_flag.rb', line 62
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
80
81
82
|
# File 'app/models/operations/feature_flag.rb', line 80
def link_reference_pattern
@link_reference_pattern ||= compose_link_reference_pattern('feature_flags', %r{(?<feature_flag>\d+)/edit})
end
|
.preload_project ⇒ Object
58
59
60
|
# File 'app/models/operations/feature_flag.rb', line 58
def preload_project
preload(:project)
end
|
.preload_relations ⇒ Object
54
55
56
|
# File 'app/models/operations/feature_flag.rb', line 54
def preload_relations
preload(strategies: [:scopes, :user_list])
end
|
.reference_pattern ⇒ Object
74
75
76
77
78
|
# File 'app/models/operations/feature_flag.rb', line 74
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
84
85
86
|
# File 'app/models/operations/feature_flag.rb', line 84
def reference_postfix
']'
end
|
.reference_prefix ⇒ Object
70
71
72
|
# File 'app/models/operations/feature_flag.rb', line 70
def reference_prefix
'[feature_flag:'
end
|
Instance Method Details
#hook_attrs ⇒ Object
111
112
113
114
115
116
117
118
|
# File 'app/models/operations/feature_flag.rb', line 111
def hook_attrs
{
id: id,
name: name,
description: description,
active: active
}
end
|
#path ⇒ Object
107
108
109
|
# File 'app/models/operations/feature_flag.rb', line 107
def path
Gitlab::Routing.url_helpers.edit_project_feature_flag_path(project, self)
end
|
96
97
98
99
100
101
102
103
104
105
|
# File 'app/models/operations/feature_flag.rb', line 96
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
89
90
91
92
93
94
|
# File 'app/models/operations/feature_flag.rb', line 89
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
|