Class: Covered::Policy::Autoload
- Inherits:
-
Object
- Object
- Covered::Policy::Autoload
- Defined in:
- lib/covered/policy.rb
Instance Method Summary collapse
- #call ⇒ 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.
69 70 71 |
# File 'lib/covered/policy.rb', line 69 def initialize(name) @name = name end |
Instance Method Details
#call ⇒ Object
85 86 87 |
# File 'lib/covered/policy.rb', line 85 def call(...) self.new.call(...) end |
#new ⇒ Object
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_s ⇒ Object
89 90 91 |
# File 'lib/covered/policy.rb', line 89 def to_s "\#<#{self.class} loading #{@name}>" end |