Class: WriteexcelOnRails::Handlers::WriteExcelTemplateHandler

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

Instance Method Summary collapse

Instance Method Details

#call(template) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/writeexcel_on_rails.rb', line 6

def call(template)
  %{
    Tempfile.open('writeexcel').tap do |tmp|
      WriteExcel.new(tmp.path).tap do |workbook|
        #{template.source}
      end.close
    end.tap(&:rewind).read
  }
end