Class: CbuilderTemplate

Inherits:
Cbuilder
  • Object
show all
Defined in:
lib/cbuilder_template.rb

Instance Method Summary collapse

Methods inherited from Cbuilder

encode, #set!, #set_collection!, #target!

Constructor Details

#initialize(context, *args) ⇒ CbuilderTemplate

Returns a new instance of CbuilderTemplate.



2
3
4
5
# File 'lib/cbuilder_template.rb', line 2

def initialize(context, *args)
  @context = context
  super(*args)
end

Instance Method Details

#partial!(options, locals = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/cbuilder_template.rb', line 7

def partial!(options, locals = {})
  case options
  when Hash
    options[:locals] ||= {}
    options[:locals].merge!(:csv => self)
    @context.render(options.reverse_merge(:formats => [:csv]))
  else
    @context.render(:partial => options, :locals => locals.merge(:csv => self), :formats => [:csv])
  end
end