class Dry::Component::Loader::Component

Attributes

file[R]
identifier[R]
loader[R]
path[R]

Public Class Methods

new(loader, input) click to toggle source
# File lib/dry/component/loader.rb, line 10
def initialize(loader, input)
  @loader = loader

  @identifier = input.to_s.gsub(loader.path_separator, loader.namespace_separator)
  if loader.default_namespace
    re = /^#{Regexp.escape(loader.default_namespace)}#{Regexp.escape(loader.namespace_separator)}/
    @identifier = @identifier.sub(re, '')
  end

  @path = input.to_s.gsub(loader.namespace_separator, loader.path_separator)
  @file = "#{path}.rb"
end

Public Instance Methods

constant() click to toggle source
# File lib/dry/component/loader.rb, line 27
def constant
  Inflecto.constantize(constant_name)
end
instance(*args) click to toggle source
# File lib/dry/component/loader.rb, line 31
def instance(*args)
  constant.new(*args)
end
namespaces() click to toggle source
# File lib/dry/component/loader.rb, line 23
def namespaces
  identifier.split(loader.namespace_separator).map(&:to_sym)
end

Private Instance Methods

constant_name() click to toggle source
# File lib/dry/component/loader.rb, line 37
def constant_name
  Inflecto.camelize(path)
end