Module: Decisive::DSL

Defined in:
lib/decisive/template_handler.rb

Instance Method Summary collapse

Instance Method Details

#csv(records, filename:, stream: true, &block) ⇒ Object



57
58
59
60
61
62
63
64
65
# File 'lib/decisive/template_handler.rb', line 57

def csv records, filename:, stream: true, &block
  if stream
    raise StreamingNotEnabledByControllerError unless controller.is_a?(ActionController::Live)
    raise StreamIncompatibleBlockArgumentError if block.arity != 0
    StreamContext.new([], records, filename, &block)
  else
    RenderContext.new(records, filename, block)
  end
end

#xls(worksheets = nil, filename:, &block) ⇒ Object



67
68
69
70
71
72
73
# File 'lib/decisive/template_handler.rb', line 67

def xls worksheets=nil, filename:, &block
  if worksheets
    XLSContext.new(worksheets, filename, block)
  else
    XLSWithWorksheetsContext.new(filename, [], &block)
  end
end