class Covered::Policy::Autoload
def call(...)
def call(...) self.new.call(...) end
def initialize(name)
def initialize(name) @name = name end
def new
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 snake_case(string)
def snake_case(string) return string.gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). tr("-", "_"). downcase end
def to_s
def to_s "\#<#{self.class} loading #{@name}>" end