Top Level Namespace

Defined Under Namespace

Modules: Enumerable, Kernel, Webby Classes: ERB, Hash, String, Time

Instance Method Summary collapse

Instance Method Details

#try_require(lib, gemname = nil) ⇒ Object

call-seq:

try_require( library, gemname = nil )    => true or false

Try to laod the given library using the built-in require, but do not raise a LoadError if unsuccessful. Returns true if the library was successfully loaded; returns false otherwise.

If a gemname is given, then the “gem gemname” command will be called before the library is loaded.



142
143
144
145
146
147
148
# File 'lib/webby.rb', line 142

def try_require( lib, gemname = nil )
  gem gemname unless gemname.nil?
  require lib
  true
rescue LoadError
  false
end