diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 03:08:59 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 03:08:59 +0000 |
commit | b57142452211f98175ac75f473741c67988867f5 (patch) | |
tree | 504811360676d8b05aaa6249ad695488588be97d /lib/feature | |
parent | b8e272100415ae1a550a455f4ad091fccb692a1e (diff) | |
download | gitlab-ce-b57142452211f98175ac75f473741c67988867f5.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/feature')
-rw-r--r-- | lib/feature/definition.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/feature/definition.rb b/lib/feature/definition.rb index 0ba1bdc4799..24f4cb3dbf0 100644 --- a/lib/feature/definition.rb +++ b/lib/feature/definition.rb @@ -13,6 +13,12 @@ class Feature end end + TYPES.each do |type, _| + define_method("#{type}?") do + attributes[:type].to_sym == type + end + end + def initialize(path, opts = {}) @path = path @attributes = {} @@ -94,6 +100,10 @@ class Feature @definitions = load_all! end + def has_definition?(key) + definitions.has_key?(key.to_sym) + end + def valid_usage!(key, type:, default_enabled:) if definition = definitions[key.to_sym] definition.valid_usage!(type_in_code: type, default_enabled_in_code: default_enabled) @@ -119,10 +129,6 @@ class Feature private def load_all! - # We currently do not load feature flag definitions - # in production environments - return [] unless Gitlab.dev_or_test_env? - paths.each_with_object({}) do |glob_path, definitions| load_all_from_path!(definitions, glob_path) end |