Sha256: 3f0f4ca9485c2c37e65ab29605cbd7dbafa76126c456c46b31b83a02fa7975aa
Contents?: true
Size: 935 Bytes
Versions: 3
Compression:
Stored size: 935 Bytes
Contents
module RightSupport module KernelExtensions # Attempt to require one or more source files; if the require succeeds (or # if the files have already been successfully required), yield to the block. # # This method is useful to conditionally define code depending on the availability # of gems or standard-library source files. # # === Parameters # Uses a parameters glob to pass all of its parameters transparently through to # Kernel#require. # # === Block # The block will be called if the require succeeds (if it does not raise LoadError). # # === Return # Preserves the return value of Kernel#require (generally either true or false). def if_require_succeeds(*args) result = require(*args) yield if block_given? return result rescue LoadError => e return false end end end class Object include RightSupport::KernelExtensions end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
right_support-0.9.4 | lib/right_support/kernel_extensions.rb |
right_support-0.9.3 | lib/right_support/kernel_extensions.rb |
right_support-0.8.0 | lib/right_support/kernel_extensions.rb |