module Subledger::Domain::Roles::DescribableReportRendering

Attributes

description[RW]
reference[RW]

Public Class Methods

raise_unless_creatable(args) click to toggle source
# File lib/subledger/domain/roles/describable_report_rendering.rb, line 7
def self.raise_unless_creatable args
  report = args[:report]

  if report.nil? or not report.kind_of? Report
    raise DescribableReportRenderingError, ':report is required and must be a Report'
  end

  description = report.description

  if description.nil? or not description.kind_of? String
    raise DescribableReportRenderingError, ':report :description is required and must be a String'
  end

  reference = report.reference

  if not reference.nil? and reference !~ URI.regexp
    raise DescribableReportRenderingError, ':report :reference must be a URL'
  end

end

Private Instance Methods

describable_report_rendering(args) click to toggle source
# File lib/subledger/domain/roles/describable_report_rendering.rb, line 30
def describable_report_rendering args
  description = args[:description]
  reference   = args[:reference]
  report      = args[:report]

  if description.nil?
    @description = report.nil? ? nil : report.description
  else
    @description = description.encode('UTF-8')
  end

  if reference.nil?
    @reference = report.nil? ? nil : report.reference
  else
    @reference = reference.encode('UTF-8')
  end
end