class Autoload
Lazily loads a report class when it is first used.
Definitions
def initialize(name)
Initialize an autoloaded report with the given constant name.
Signature
-
parameter
nameString The report class name under
module Covered.
Implementation
def initialize(name)
@name = name
end
def new
Instantiate the report class.
Signature
-
returns
Object A new report instance.
Implementation
def new
begin
klass = Covered.const_get(@name)
rescue NameError
require_relative(snake_case(@name))
end
klass = Covered.const_get(@name)
return klass.new
end
def call(...)
Instantiate the report and call it. Arguments are forwarded to the report.
Implementation
def call(...)
self.new.call(...)
end
def to_s
A human-readable representation of this autoloaded report.
Signature
-
returns
String A debug representation of the autoloader.
Implementation
def to_s
"\#<#{self.class} loading #{@name}>"
end