Class: Yj::Render

Inherits:
Object
  • Object
show all
Defined in:
lib/yj/render.rb

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ Render

Returns a new instance of Render.



3
4
5
# File 'lib/yj/render.rb', line 3

def initialize(context)
  @context = context
end

Instance Method Details

#call(options) ⇒ Object



7
8
9
10
11
12
# File 'lib/yj/render.rb', line 7

def call(options)
  options[:locals] ||= {}
  options[:locals].merge!(r: self, _partial: true) if options[:collection].present?
  yaml = @context.render options
  YAML.load(yaml).to_json
end