Class: Covered::Policy::Autoload

Inherits:
Object
  • Object
show all
Defined in:
lib/covered/policy.rb

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Autoload

Returns a new instance of Autoload.



69
70
71
# File 'lib/covered/policy.rb', line 69

def initialize(name)
	@name = name
end

Instance Method Details

#callObject



85
86
87
# File 'lib/covered/policy.rb', line 85

def call(...)
	self.new.call(...)
end

#newObject



73
74
75
76
77
78
79
80
81
82
83
# File 'lib/covered/policy.rb', line 73

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

#to_sObject



89
90
91
# File 'lib/covered/policy.rb', line 89

def to_s
	"\#<#{self.class} loading #{@name}>"
end