Class: ROM::AutoRegistration

Inherits:
Object
  • Object
show all
Extended by:
Initializer
Defined in:
lib/rom/setup/auto_registration.rb

Overview

AutoRegistration is used to load component files automatically from the provided directory path

Constant Summary collapse

NamespaceType =
Types::Strict::Bool | Types::Strict::String
PathnameType =
Types.Constructor(Pathname, &Kernel.method(:Pathname))
DEFAULT_MAPPING =
{
  relations: :relations,
  mappers: :mappers,
  commands: :commands
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Initializer

extended

Instance Attribute Details

#component_dirsHash (readonly)

Returns component => dir-name map.

Returns:

  • (Hash)

    component => dir-name map



40
# File 'lib/rom/setup/auto_registration.rb', line 40

option :component_dirs, type: Types::Strict::Hash, default: -> { DEFAULT_MAPPING }

#directoryPathname (readonly)

Returns The root path.

Returns:

  • (Pathname)

    The root path



30
# File 'lib/rom/setup/auto_registration.rb', line 30

param :directory, type: PathnameType

#globsHash (readonly)

Returns File globbing functions for each component dir.

Returns:

  • (Hash)

    File globbing functions for each component dir



44
45
46
47
48
49
50
# File 'lib/rom/setup/auto_registration.rb', line 44

option :globs, default: -> {
  Hash[
    component_dirs.map { |component, path|
      [component, directory.join("#{path}/**/*.rb")]
    }
  ]
}

#namespaceBoolean, String (readonly)

Returns The name of the top level namespace or true/false which enables/disables default top level namespace inferred from the dir name.

Returns:

  • (Boolean, String)

    The name of the top level namespace or true/false which enables/disables default top level namespace inferred from the dir name



36
# File 'lib/rom/setup/auto_registration.rb', line 36

option :namespace, type: NamespaceType, default: -> { true }

Instance Method Details

#commandsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Load command files



62
63
64
# File 'lib/rom/setup/auto_registration.rb', line 62

def commands
  load_entities(:commands)
end

#mappersObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Load mapper files



69
70
71
# File 'lib/rom/setup/auto_registration.rb', line 69

def mappers
  load_entities(:mappers)
end

#relationsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Load relation files



55
56
57
# File 'lib/rom/setup/auto_registration.rb', line 55

def relations
  load_entities(:relations)
end