Module: RightSupport::Ruby::ObjectExtensions

Included in:
Object
Defined in:
lib/right_support/ruby/object_extensions.rb

Instance Method Summary collapse

Instance Method Details

#require_succeeds?(*args) ⇒ Boolean

Attempt to require one or more source files.

This method is useful to conditionally define code depending on the availability of gems or standard-library source files.

Parameters

Forwards all parameters transparently through to Kernel#require.

Return

Returns true or false

Returns:

  • (Boolean)


35
36
37
38
39
40
# File 'lib/right_support/ruby/object_extensions.rb', line 35

def require_succeeds?(*args)
  require(*args)
  return true
rescue LoadError => e
  return false
end