Class: Covered::Policy::Autoload
- Inherits:
-
Object
- Object
- Covered::Policy::Autoload
- Defined in:
- lib/covered/policy.rb
Instance Method Summary collapse
- #call(*args) ⇒ Object
-
#initialize(name) ⇒ Autoload
constructor
A new instance of Autoload.
- #new ⇒ Object
- #to_s ⇒ Object
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 |
#new ⇒ Object
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_s ⇒ Object
114 115 116 |
# File 'lib/covered/policy.rb', line 114 def to_s "\#<#{self.class} loading #{@name}>" end |