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.



94
95
96
# File 'lib/covered/policy.rb', line 94

def initialize(name)
	@name = name
end

Instance Method Details

#call(*args) ⇒ Object



110
111
112
# File 'lib/covered/policy.rb', line 110

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

#newObject



98
99
100
101
102
103
104
105
106
107
108
# File 'lib/covered/policy.rb', line 98

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



114
115
116
# File 'lib/covered/policy.rb', line 114

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