Sha256: 28ad675895f876f9dfb72401a89d9d2b4b0f20632986f454f9fd55748671dc76

Contents?: true

Size: 551 Bytes

Versions: 30

Compression:

Stored size: 551 Bytes

Contents

# frozen_string_literal: true
module Hako
  class Loader
    # @param [Module] base_module
    # @param [String] base_path
    def initialize(base_module, base_path)
      @base_module = base_module
      @base_path = base_path
    end

    # @param [String] name
    # @return [Module]
    def load(name)
      require "#{@base_path}/#{name}"
      @base_module.const_get(camelize(name))
    end

    private

    # @param [String] name
    # @return [String]
    def camelize(name)
      name.split('_').map(&:capitalize).join('')
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
hako-1.1.0 lib/hako/loader.rb
hako-1.0.1 lib/hako/loader.rb
hako-1.0.0 lib/hako/loader.rb
hako-0.27.0 lib/hako/loader.rb
hako-0.26.0 lib/hako/loader.rb
hako-0.25.2 lib/hako/loader.rb
hako-0.25.1 lib/hako/loader.rb
hako-0.25.0 lib/hako/loader.rb
hako-0.24.0 lib/hako/loader.rb
hako-0.23.0 lib/hako/loader.rb
hako-0.22.0 lib/hako/loader.rb
hako-0.21.1 lib/hako/loader.rb
hako-0.21.0 lib/hako/loader.rb
hako-0.20.3 lib/hako/loader.rb
hako-0.20.2 lib/hako/loader.rb
hako-0.20.1 lib/hako/loader.rb
hako-0.20.0 lib/hako/loader.rb
hako-0.19.0 lib/hako/loader.rb
hako-0.18.1 lib/hako/loader.rb
hako-0.18.0 lib/hako/loader.rb