class Subledger::Domain::ReportRendering
Constants
- BALANCED_ACCOUNTS_SEMAPHORE
- TOTAL_ACCOUNTS_SEMAPHORE
Attributes
balanced_accounts[R]
book[R]
effective_at[R]
rendered_at[R]
report[R]
total_accounts[R]
Public Class Methods
active_klass()
click to toggle source
TODO create uses active_klass
, should use creation_klass
# File lib/subledger/domain/report_rendering.rb, line 42 def self.active_klass building_klass end
building_klass()
click to toggle source
# File lib/subledger/domain/report_rendering.rb, line 37 def self.building_klass BuildingReportRendering end
completed_klass()
click to toggle source
# File lib/subledger/domain/report_rendering.rb, line 46 def self.completed_klass CompletedReportRendering end
new(args)
click to toggle source
# File lib/subledger/domain/report_rendering.rb, line 50 def initialize args describable_report_rendering args identifiable args storable args @book = args[:book] @report = args[:report] @effective_at = round args[:effective_at] @rendered_at = utc_or_now args[:rendered_at] @balanced_accounts = args[:balanced_accounts] || 0 @total_accounts = args[:total_accounts] || 0 specialized_initialization args end
post_keys()
click to toggle source
# File lib/subledger/domain/report_rendering.rb, line 25 def self.post_keys [ :description, :reference, :report, :effective_at ] end
root_klass()
click to toggle source
# File lib/subledger/domain/report_rendering.rb, line 29 def self.root_klass ReportRendering end
sub_klasses()
click to toggle source
# File lib/subledger/domain/report_rendering.rb, line 33 def self.sub_klasses [ building_klass, completed_klass ] end
Private Class Methods
raise_unless_creatable(args)
click to toggle source
# File lib/subledger/domain/report_rendering.rb, line 90 def self.raise_unless_creatable args book = args[:book] if book.nil? or not book.kind_of? Book raise ReportRenderingError, ':book is required and must be a Book' elsif UUID.invalid? book.id raise ReportRenderingError, ':book must have a valid :id' end report = args[:report] if report.nil? or not report.kind_of? Report raise ReportRenderingError, ':report is required and must be a Report' elsif UUID.invalid? report.id raise ReportRenderingError, ':report must have a valid :id' end effective_at = args[:effective_at] if effective_at.nil? or not effective_at.kind_of? Time raise ReportRenderingError, ':effective_at is required and must be a Time' end end
Public Instance Methods
progress()
click to toggle source
# File lib/subledger/domain/report_rendering.rb, line 66 def progress if total_accounts.zero? 0 else ( ( balanced_accounts.to_f / total_accounts ) * 99 ).to_i end end
Private Instance Methods
increase_balanced_accounts_by(count)
click to toggle source
# File lib/subledger/domain/report_rendering.rb, line 129 def increase_balanced_accounts_by count BALANCED_ACCOUNTS_SEMAPHORE.synchronize do @balanced_accounts += count end end
increase_total_accounts_by(count)
click to toggle source
# File lib/subledger/domain/report_rendering.rb, line 121 def increase_total_accounts_by count TOTAL_ACCOUNTS_SEMAPHORE.synchronize do @total_accounts += count end end
round(effective_at)
click to toggle source
# File lib/subledger/domain/report_rendering.rb, line 115 def round effective_at Time.at( utc_or_nil( effective_at ).to_i ).utc end
specialized_initialization(args)
click to toggle source
# File lib/subledger/domain/report_rendering.rb, line 135 def specialized_initialization args end