Class: ROM::AutoRegistration
- Inherits:
-
Object
- Object
- ROM::AutoRegistration
- Extended by:
- Initializer
- Defined in:
- lib/rom/compat/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))
- InflectorType =
Types.Strict(Dry::Inflector)
- DEFAULT_MAPPING =
{ relations: :relations, mappers: :mappers, commands: :commands }.freeze
Instance Attribute Summary collapse
-
#component_dirs ⇒ Hash
readonly
Component => dir-name map.
-
#directory ⇒ Pathname
readonly
The root path.
-
#globs ⇒ Hash
readonly
File globbing functions for each component dir.
-
#inflector ⇒ Dry::Inflector
readonly
private
String inflector.
-
#namespace ⇒ Boolean, String
readonly
The name of the top level namespace or true/false which enables/disables default top level namespace inferred from the dir name.
Instance Method Summary collapse
-
#commands ⇒ Object
private
Load command files.
-
#mappers ⇒ Object
private
Load mapper files.
-
#relations ⇒ Object
private
Load relation files.
Instance Attribute Details
#component_dirs ⇒ Hash (readonly)
Returns component => dir-name map.
45 |
# File 'lib/rom/compat/auto_registration.rb', line 45 option :component_dirs, type: Types::Strict::Hash, default: -> { DEFAULT_MAPPING } |
#directory ⇒ Pathname (readonly)
Returns The root path.
35 |
# File 'lib/rom/compat/auto_registration.rb', line 35 param :directory, type: PathnameType |
#globs ⇒ Hash (readonly)
Returns File globbing functions for each component dir.
49 50 51 52 53 |
# File 'lib/rom/compat/auto_registration.rb', line 49 option :globs, default: lambda { component_dirs.map { |component, path| [component, directory.join("#{path}/**/*.rb")] }.to_h } |
#inflector ⇒ Dry::Inflector (readonly)
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.
Returns String inflector.
58 |
# File 'lib/rom/compat/auto_registration.rb', line 58 option :inflector, type: InflectorType, default: -> { Inflector } |
#namespace ⇒ Boolean, 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.
41 |
# File 'lib/rom/compat/auto_registration.rb', line 41 option :namespace, type: NamespaceType, default: -> { true } |
Instance Method Details
#commands ⇒ Object
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
70 71 72 |
# File 'lib/rom/compat/auto_registration.rb', line 70 def commands load_entities(:commands) end |
#mappers ⇒ Object
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
77 78 79 |
# File 'lib/rom/compat/auto_registration.rb', line 77 def mappers load_entities(:mappers) end |
#relations ⇒ Object
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
63 64 65 |
# File 'lib/rom/compat/auto_registration.rb', line 63 def relations load_entities(:relations) end |