Class: Gitlab::WikiPages::FrontMatterParser::Block
- Inherits:
-
Object
- Object
- Gitlab::WikiPages::FrontMatterParser::Block
show all
- Includes:
- Utils::StrongMemoize
- Defined in:
- lib/gitlab/wiki_pages/front_matter_parser.rb
Instance Method Summary
collapse
#clear_memoization, #strong_memoize, #strong_memoized?
Constructor Details
#initialize(delim = nil, lang = '', text = nil) ⇒ Block
Returns a new instance of Block.
55
56
57
58
|
# File 'lib/gitlab/wiki_pages/front_matter_parser.rb', line 55
def initialize(delim = nil, lang = '', text = nil)
@lang = lang.downcase.presence || Gitlab::FrontMatter::DELIM_LANG[delim]
@text = text
end
|
Instance Method Details
#data ⇒ Object
60
61
62
63
64
|
# File 'lib/gitlab/wiki_pages/front_matter_parser.rb', line 60
def data
@data ||= YAML.safe_load(text, symbolize_names: true)
rescue Psych::DisallowedClass, Psych::SyntaxError => error
raise ParseError, error.message
end
|
#error ⇒ Object
70
71
72
|
# File 'lib/gitlab/wiki_pages/front_matter_parser.rb', line 70
def error
strong_memoize(:error) { no_match? || too_long? || not_yaml? || not_mapping? }
end
|
#valid? ⇒ Boolean
66
67
68
|
# File 'lib/gitlab/wiki_pages/front_matter_parser.rb', line 66
def valid?
error.nil?
end
|