Class: FrontMatterParser::Loader::Yaml
- Inherits:
-
Object
- Object
- FrontMatterParser::Loader::Yaml
- Defined in:
- lib/front_matter_parser/loader/yaml.rb
Overview
FrontMatterParser::Loader that uses YAML library
Instance Attribute Summary collapse
-
#whitelist_classes ⇒ Object
readonly
Classes that may be parsed by #call.
Instance Method Summary collapse
-
#call(string) ⇒ Hash
Loads a hash front matter from a string.
-
#initialize(whitelist_classes: []) ⇒ Yaml
constructor
A new instance of Yaml.
Constructor Details
#initialize(whitelist_classes: []) ⇒ Yaml
Returns a new instance of Yaml.
13 14 15 |
# File 'lib/front_matter_parser/loader/yaml.rb', line 13 def initialize(whitelist_classes: []) @whitelist_classes = whitelist_classes end |
Instance Attribute Details
#whitelist_classes ⇒ Object (readonly)
Classes that may be parsed by #call.
11 12 13 |
# File 'lib/front_matter_parser/loader/yaml.rb', line 11 def whitelist_classes @whitelist_classes end |
Instance Method Details
#call(string) ⇒ Hash
Loads a hash front matter from a string
21 22 23 |
# File 'lib/front_matter_parser/loader/yaml.rb', line 21 def call(string) YAML.safe_load(string, whitelist_classes) end |