Class: EcsRails::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/ecs_rails/config.rb

Overview

Generator configuration for the directory layout (ADR-0010).

The gem RUNTIME never reads this: entities and components are keyed by class name (RFC-0002) and by the model discriminator (ADR-0002), so the registry does not care where a class file lives. This object exists purely so the generators (RFC-0008) know where to write, and so the initializer they emit can echo the chosen path.

entities_path is the single knob. Components always live in a components subdirectory of it, which is why components_path is derived rather than separately settable — ADR-0010 deliberately exposes one path, not two.

Examples:

Restoring the pre-ADR-0010 single-directory layout

# config/initializers/ecs_rails.rb
EcsRails.configure { |config| config.entities_path = "app/models" }

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



27
28
29
# File 'lib/ecs_rails/config.rb', line 27

def initialize
  @entities_path = "app/entities"
end

Instance Attribute Details

#entities_pathString

Entities land here; the default is the ADR-0010 layout. Set it to "app/models" to restore the pre-ADR-0010 single-directory layout.

Returns:

  • (String)

    the directory entities are generated into



25
26
27
# File 'lib/ecs_rails/config.rb', line 25

def entities_path
  @entities_path
end

Instance Method Details

#components_pathString

Components live in a components subdirectory of the entities path. The generated initializer collapses this directory so Zeitwerk treats the components/ segment as transparent (ADR-0010 “How it works”).

Derived rather than separately settable: ADR-0010 deliberately exposes one path, not two.

Returns:

  • (String)

    the directory components are generated into, e.g. "app/entities/components"



40
41
42
# File 'lib/ecs_rails/config.rb', line 40

def components_path
  "#{entities_path}/components"
end