Module: Dimples::Frontable
Instance Method Summary collapse
Instance Method Details
#apply_metadata(metadata) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/dimples/frontable.rb', line 22 def () .each_pair do |key, value| unless respond_to?(key.to_sym) self.class.send(:attr_accessor, key.to_sym) end send("#{key}=", value) end end |
#read_with_yaml(path) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/dimples/frontable.rb', line 3 def read_with_yaml(path) if File.extname(path) == '.yml' contents = '' = YAML.load_file(path) else contents = File.read(path) matches = contents.match(/^(-{3}\n.*?\n?)^(-{3}*$\n?)/m) if matches = YAML.load(matches[1]) contents = matches.post_match.strip end end () if contents end |