Sha256: fcf8da08a2106517a867607d0bac19eb24e506c2b0b0cacd57ea34b933a2946b

Contents?: true

Size: 792 Bytes

Versions: 1

Compression:

Stored size: 792 Bytes

Contents

# frozen_string_literal: true

require "pathname"

require "rom/support/inflector"
require "rom/types"
require_relative "base"

module ROM
  module AutoRegistrationStrategies
    # NoNamespace strategy assumes components are not defined within a namespace
    #
    # @api private
    class NoNamespace < Base
      # @!attribute [r] directory
      #   @return [Pathname] The path to dir with components
      option :directory, type: PathnameType

      # @!attribute [r] entity
      #   @return [Symbol] Component identifier
      option :entity, type: Types::Strict::Symbol

      # Load components
      #
      # @api private
      def call
        inflector.camelize(
          file.sub(%r{^#{directory}/#{entity}/}, "").sub(EXTENSION_REGEX, "")
        )
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rom-6.0.0.alpha1 lib/rom/compat/auto_registration_strategies/no_namespace.rb