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-0.17.2 lib/hako/loader.rb
hako-0.17.1 lib/hako/loader.rb
hako-0.17.0 lib/hako/loader.rb
hako-0.16.0 lib/hako/loader.rb
hako-0.15.3 lib/hako/loader.rb
hako-0.15.2 lib/hako/loader.rb
hako-0.15.1 lib/hako/loader.rb
hako-0.15.0 lib/hako/loader.rb
hako-0.14.1 lib/hako/loader.rb
hako-0.14.0 lib/hako/loader.rb