Class: Exchange::GemLoader
- Inherits:
-
Object
- Object
- Exchange::GemLoader
- Defined in:
- lib/exchange/gem_loader.rb
Overview
The gem loader takes care of loading gems without adding too many unnecessary dependencies to the gem
Constant Summary collapse
- GemNotFoundError =
The error that gets thrown if a needed gem is not available or loadable
Class.new UsageError
Instance Method Summary collapse
-
#initialize(gem) ⇒ Exchange::Gemloader
constructor
initialize the loader with a gem name.
-
#try_load ⇒ Object
Try to require the gem specified on initialization.
Constructor Details
#initialize(gem) ⇒ Exchange::Gemloader
initialize the loader with a gem name.
21 22 23 |
# File 'lib/exchange/gem_loader.rb', line 21 def initialize gem @gem = gem end |
Instance Method Details
#try_load ⇒ Object
Try to require the gem specified on initialization.
30 31 32 33 34 |
# File 'lib/exchange/gem_loader.rb', line 30 def try_load require @gem rescue LoadError => e raise GemNotFoundError.new("You specified #{@gem} to be used with Exchange, yet it is not loadable. Please install #{@gem} to be able to use it with Exchange") end |