Hi
This is an implementation question. I have various reports to be
generated in my application like PDF reports, Excel reports etc So I
tried like a main class Application report and all the other report
types its sub classes For example
TicketExcelreport < ApplicationReport
MyPdfreport < ApplicationReport
Could anybody please point what the pros and cons doing this?
This is an implementation question. I have various reports to be
generated in my application like PDF reports, Excel reports etc So I
tried like a main class Application report and all the other report
types its sub classes For example
TicketExcelreport < ApplicationReport
MyPdfreport < ApplicationReport
Could anybody please point what the pros and cons doing this?
As your reports only seem to be different views of the same data, I
would rather suggest creating #to_xls, #to_pdf and so on for Report
class, rather than subclassing it. If you think the logic invloved is
too big an instance method, maybe creating a generic PDF::Builder (or
whatever, that’s shamelessly copied from XML::Builder) would be a
better idea, that way you could reuse that “pdf building” or “xls
building” logic elsewehere.
Regards,
Felix
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.