class Fried::Test::PrependToLoadPath

Unshifts the path to {$LOAD_PATH} unless already existing

Attributes

load_path[RW]

Public Class Methods

build() click to toggle source
# File lib/fried/test/prepend_to_load_path.rb, line 12
def self.build
  new.tap do |instance|
    instance.load_path = $LOAD_PATH
  end
end
call() click to toggle source
# File lib/fried/test/prepend_to_load_path.rb, line 29
def self.call
  instance = build
  instance.()
end
new() click to toggle source
# File lib/fried/test/prepend_to_load_path.rb, line 8
def initialize
  @load_path = []
end

Public Instance Methods

call(path) click to toggle source

@param path [String, Pathname] @return [Boolean] {true} if path was added, {false} if already present

# File lib/fried/test/prepend_to_load_path.rb, line 20
def call(path)
  text_path = path.to_s

  has_path = load_path.include?(text_path)
  load_path.unshift(text_path) unless has_path

  !has_path
end