lib/thinreports/report/internal.rb in thinreports-0.8.0 vs lib/thinreports/report/internal.rb in thinreports-0.8.1
- old
+ new
@@ -10,11 +10,10 @@
attr_reader :default_layout
attr_reader :layout_registry
attr_reader :events
attr_accessor :page_create_handler
- attr_accessor :generate_handler
# @param [Thinreports::Report::Base] report
# @param options (see Thinreports::Report::Base#initialize)
def initialize(report, options)
@report = report
@@ -26,11 +25,10 @@
@pages = []
@page = nil
@page_count = 0
@page_create_handler = nil
- @generate_handler = nil
@events = Report::Events.new
end
# @see Thinreports::Report::Base#use_layout
@@ -61,14 +59,25 @@
def finalize
unless finalized?
finalize_current_page
@finalized = true
- # [DEPRECATION] Please use Report::Base#on_generate callback instead.
+ # [DEPRECATION] You can do the same implements as the :generate Event
+ # with the following code:
+ #
+ # report = Thinreports::Report.new layout: 'foo.tlf'
+ # report.start_new_page do |page|
+ # page.item(:price).value = 100000
+ # end
+ #
+ # report.pages.each do |page|
+ # page[:title] = 'Common Title'
+ # end
+ #
+ # report.generate filename: 'foo.pdf'
+ #
events.dispatch(Report::Events::Event.new(:generate,
@report, nil, pages))
-
- @generate_handler.call(pages) if @generate_handler
end
end
def finalized?
@finalized