Sha256: a70bb987c8013f815d8a282fa5a8155db487e1d1639313b1296e9fa7741e8c27
Contents?: true
Size: 846 Bytes
Versions: 32
Compression:
Stored size: 846 Bytes
Contents
class Ticket::Glance def self.report(reports) reports.each do |mthd, klass| # Define the getter method for this report class_eval(<<-EOS, __FILE__, __LINE__) def #{mthd} @#{mthd} ||= #{klass}.new(@parent) end EOS # Delegate methods to the created method delegate(*klass.reporting_methods, :prefix => true, :to => mthd) end end report :available => Ticket::Reports::Available, :sold => Ticket::Reports::Sold, :comped => Ticket::Reports::Comped, :sales => Ticket::Reports::Sales def initialize(parent) @parent = parent end def as_json(options ={}) { :tickets => { :comped => comped.total, :available => available.total, :sold => { :gross => sales.total } } } end end
Version data entries
32 entries across 32 versions & 1 rubygems