Sha256: a3a22d4c5fdc62a64b7bf3d83261c19e5c878bbf1880b4180686b3d2df92622b
Contents?: true
Size: 714 Bytes
Versions: 3
Compression:
Stored size: 714 Bytes
Contents
require 'inflecto' module Dry module Component class Loader IDENTIFIER_SEPARATOR = '.'.freeze PATH_SEPARATOR = '/'.freeze attr_reader :identifier, :path, :file def initialize(input) @identifier = input.to_s.gsub(PATH_SEPARATOR, IDENTIFIER_SEPARATOR) @path = input.to_s.gsub(IDENTIFIER_SEPARATOR, PATH_SEPARATOR) @file = "#{path}.rb" end def namespaces identifier.split(IDENTIFIER_SEPARATOR).map(&:to_sym) end def constant Inflecto.constantize(name) end def instance(*args) constant.new(*args) end private def name Inflecto.camelize(path) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dry-component-0.3.0 | lib/dry/component/loader.rb |
dry-component-0.2.0 | lib/dry/component/loader.rb |
dry-component-0.1.0 | lib/dry/component/loader.rb |