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.
- #to_s ⇒ Object
Constructor Details
#initialize(name) ⇒ Autoload
Returns a new instance of Autoload.
92 93 94 |
# File 'lib/covered/policy.rb', line 92 def initialize(name) @name = name end |
Instance Method Details
#call(*args) ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/covered/policy.rb', line 96 def call(*args) begin klass = Covered.const_get(@name) rescue NameError require_relative @name.downcase end begin klass = Covered.const_get(@name) return klass.new.call(*args) rescue NameError warn "Could not find #{name} call Ignoring." end end |
#to_s ⇒ Object
112 113 114 |
# File 'lib/covered/policy.rb', line 112 def to_s "\#<#{self.class} loading #{@name}>" end |