class Subledger::Domain::CompletedReportRendering

Attributes

balance[R]
categories[R]
completed_at[R]
location[R]
warnings[R]

Public Class Methods

sub_klasses() click to toggle source
# File lib/subledger/domain/report_rendering.rb, line 166
def self.sub_klasses
  [ completed_klass ]
end

Public Instance Methods

progress() click to toggle source
# File lib/subledger/domain/report_rendering.rb, line 170
def progress
  100
end
to_json() click to toggle source
# File lib/subledger/domain/report_rendering.rb, line 174
def to_json
  @json ||= if location[0..4] == 's3://'
              ExceptionHandler.new( :name => 'completed_report_rendering to_json' ).with_retry do
                s3_bucket.objects[id].read
              end
            elsif location[0..6] == 'file://'
              File.open( location[7..-1], 'r' ).read
            else
              raise ReportRenderingError, "unknown URL scheme: #{location}"
            end
end

Private Instance Methods

as_hash() click to toggle source
# File lib/subledger/domain/report_rendering.rb, line 217
def as_hash
  @hash ||= MultiJson.load to_json
end
s3_bucket() click to toggle source
# File lib/subledger/domain/report_rendering.rb, line 213
def s3_bucket
  @s3_bucket ||= Store::Aws.s3_client.buckets[RENDERED_REPORTS_BUCKET]
end
specialized_initialization(args) click to toggle source
# File lib/subledger/domain/report_rendering.rb, line 221
def specialized_initialization args
  @completed_at = utc_or_nil args[:completed_at]
  @location     = args[:location]
  @json         = args[:json]

  @balance      = nil
  @categories   = nil
  @hash         = nil
  @warnings     = nil
end