Sha256: 8dac47ab668aa816d7e085a12dd6fcb5473ad896a0f86610d0cdc21d5de8960a

Contents?: true

Size: 988 Bytes

Versions: 1

Compression:

Stored size: 988 Bytes

Contents

require 'forwardable'
module RequireDir
  module Initializer
    def self.included(base)
      base.instance_eval do
        class << self
          attr_accessor :__require_dir_loader
          extend Forwardable
          def_delegators :@__require_dir_loader, :dir, :dir_r, :require_dir, :require_dir_r

          def __require_dir_init(source, offset = 0, options = {})
            project_folder            = __require_dir_project_folder(source: source, offset: offset)
            self.__require_dir_loader = __require_dir_create_loader(options, project_folder)
          end

          def __require_dir_create_loader(options, project_folder)
            RequireDir::Loader.new(project_folder, options)
          end

          def __require_dir_project_folder(source:, offset: 0)
            dirs_up = ''
            offset.times { dirs_up << '/..' } if offset > 0
            File.dirname(File.expand_path(source + dirs_up))
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
require_dir-2.0.0 lib/require_dir/initializer.rb