Class: PufferPages::Handlers::Yaml

Inherits:
Base
  • Object
show all
Defined in:
lib/puffer_pages/handlers/yaml.rb

Instance Attribute Summary

Attributes inherited from Base

#type

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from PufferPages::Handlers::Base

Instance Method Details

#codemirror_modeObject



13
14
15
# File 'lib/puffer_pages/handlers/yaml.rb', line 13

def codemirror_mode
  'text/x-liquid-yaml'
end

#process(renderable, context = nil) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/puffer_pages/handlers/yaml.rb', line 4

def process renderable, context = nil
  renderable.self_and_ancestors.where(handler: 'yaml').reverse.each_with_object({}) do |renderable, result|
    load_arguments = [renderable.render(context)]
    load_arguments.push renderable.name if YAML.method(:load).arity == -2
    hash = YAML.load *load_arguments
    result.deep_merge! hash
  end
end