Module: YAML
- Defined in:
- lib/util/yaml.rb
Overview
Note:
The standard YAML module is transitively required when using this extension.
Extension to the YAML module of the standard library.
Class Method Summary collapse
-
.from_file(filename, fallback = false) ⇒ Object
Safely load the content of a file.
Class Method Details
.from_file(filename, fallback = false) ⇒ Object
Safely load the content of a file.
11 12 13 14 15 16 17 |
# File 'lib/util/yaml.rb', line 11 def self.from_file filename, fallback = false fn = filename.to_s return fallback unless File.file? fn and File.readable? fn File.open fn, 'r:bom|utf-8' do |f| self.load f, filename: fn, fallback: fallback end end |