Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2019-03-20 23:01:27 +0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2019-03-20 23:44:29 +0300
commit6264694d572c48f4517f8999a61cc6e0fb32ccae (patch)
treeea9c19c46eb4d37bf5e3f70328e1992bfe902805 /app/models/concerns/cache_markdown_field.rb
parent69dc893da3f19d465c12c6c183270daf38df14b3 (diff)
Rename the hidden option to whitelisted
Diffstat (limited to 'app/models/concerns/cache_markdown_field.rb')
-rw-r--r--app/models/concerns/cache_markdown_field.rb13
1 files changed, 7 insertions, 6 deletions
diff --git a/app/models/concerns/cache_markdown_field.rb b/app/models/concerns/cache_markdown_field.rb
index 4212224b66a..15d8d58b9b5 100644
--- a/app/models/concerns/cache_markdown_field.rb
+++ b/app/models/concerns/cache_markdown_field.rb
@@ -7,7 +7,7 @@
# cache_markdown_field :foo
# cache_markdown_field :bar
# cache_markdown_field :baz, pipeline: :single_line
-# cache_markdown_field :baz, hidden: false
+# cache_markdown_field :baz, whitelisted: true
#
# Corresponding foo_html, bar_html and baz_html fields should exist.
module CacheMarkdownField
@@ -41,9 +41,9 @@ module CacheMarkdownField
markdown_fields.map { |field| html_field(field) }
end
- def hidden_html_fields
+ def html_fields_whitelisted
markdown_fields.each_with_object([]) do |field, fields|
- if @data[field].fetch(:hidden, true)
+ if @data[field].fetch(:whitelisted, false)
fields << html_field(field)
end
end
@@ -159,13 +159,14 @@ module CacheMarkdownField
def attributes
attrs = attributes_before_markdown_cache
html_fields = cached_markdown_fields.html_fields
- hidden_html_fields = cached_markdown_fields.hidden_html_fields
+ whitelisted = cached_markdown_fields.html_fields_whitelisted
+ exclude_fields = html_fields - whitelisted
- hidden_html_fields.each do |field|
+ exclude_fields.each do |field|
attrs.delete(field)
end
- if (html_fields - hidden_html_fields).empty?
+ if whitelisted.empty?
attrs.delete('cached_markdown_version')
end