Sha256: 62631eafc1b522a9468830172755913920a110dd747bb0f74a3c41a35557afc5

Contents?: true

Size: 714 Bytes

Versions: 6

Compression:

Stored size: 714 Bytes

Contents

# frozen_string_literal: true

require 'pathname'

require 'rom/support/inflector'
require 'rom/setup/auto_registration_strategies/base'

module ROM
  module AutoRegistrationStrategies
    # WithNamespace strategy assumes components are defined within a namespace
    # that matches top-level directory name.
    #
    # @api private
    class WithNamespace < Base
      # @!attribute [r] directory
      #   @return [Pathname] The path to dir with components
      option :directory, type: PathnameType

      # Load components
      #
      # @api private
      def call
        Inflector.camelize(
          file.sub(/^#{directory.dirname}\//, '').sub(EXTENSION_REGEX, '')
        )
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rom-core-5.1.2 lib/rom/setup/auto_registration_strategies/with_namespace.rb
rom-core-5.1.1 lib/rom/setup/auto_registration_strategies/with_namespace.rb
rom-core-5.1.0 lib/rom/setup/auto_registration_strategies/with_namespace.rb
rom-core-5.0.2 lib/rom/setup/auto_registration_strategies/with_namespace.rb
rom-core-5.0.1 lib/rom/setup/auto_registration_strategies/with_namespace.rb
rom-core-5.0.0 lib/rom/setup/auto_registration_strategies/with_namespace.rb