Class: Gitlab::MarkdownCache::FieldData

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/markdown_cache/field_data.rb

Overview

Knows about the relationship between markdown and html field names, and stores the rendering contexts for the latter

Instance Method Summary collapse

Constructor Details

#initializeFieldData

Returns a new instance of FieldData.


8
9
10
# File 'lib/gitlab/markdown_cache/field_data.rb', line 8

def initialize
  @data = {}
end

Instance Method Details

#html_field(markdown_field) ⇒ Object


18
19
20
# File 'lib/gitlab/markdown_cache/field_data.rb', line 18

def html_field(markdown_field)
  "#{markdown_field}_html"
end

#html_fieldsObject


22
23
24
# File 'lib/gitlab/markdown_cache/field_data.rb', line 22

def html_fields
  @html_fields ||= markdown_fields.map { |field| html_field(field) }
end

#html_fields_whitelistedObject


26
27
28
29
30
31
32
# File 'lib/gitlab/markdown_cache/field_data.rb', line 26

def html_fields_whitelisted
  markdown_fields.each_with_object([]) do |field, fields|
    if @data[field].fetch(:whitelisted, false)
      fields << html_field(field)
    end
  end
end

#markdown_fieldsObject


14
15
16
# File 'lib/gitlab/markdown_cache/field_data.rb', line 14

def markdown_fields
  @data.keys
end