Class: Servus::Config
- Inherits:
-
Object
- Object
- Servus::Config
- Defined in:
- lib/servus/config.rb
Overview
Instance Attribute Summary collapse
-
#events_dir ⇒ String
The directory where event handlers are located.
-
#guards_dir ⇒ String
The directory where guard classes are located.
-
#include_default_guards ⇒ Boolean
Whether to include the default built-in guards (EnsurePresent, EnsurePositive).
-
#schemas_dir ⇒ String
The directory where JSON schema files are located.
-
#services_dir ⇒ String
The directory where services are located.
-
#strict_event_validation ⇒ Boolean
Whether to validate that all event handlers subscribe to events that are actually emitted by services.
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
private
Initializes a new configuration with default values.
-
#schema_dir_for(service_namespace) ⇒ String
Returns the directory containing a service's schema files.
-
#schema_path_for(service_namespace, type) ⇒ String
Returns the full path to a service's schema file.
Constructor Details
#initialize ⇒ Config
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.
Initializes a new configuration with default values.
62 63 64 65 66 67 68 69 70 |
# File 'lib/servus/config.rb', line 62 def initialize @guards_dir = 'app/guards' @events_dir = 'app/events' @schemas_dir = 'app/schemas' @services_dir = 'app/services' @strict_event_validation = true @include_default_guards = true end |
Instance Attribute Details
#events_dir ⇒ String
The directory where event handlers are located.
Defaults to Rails.root/app/events in Rails applications.
30 31 32 |
# File 'lib/servus/config.rb', line 30 def events_dir @events_dir end |
#guards_dir ⇒ String
The directory where guard classes are located.
Defaults to Rails.root/app/guards in Rails applications.
52 53 54 |
# File 'lib/servus/config.rb', line 52 def guards_dir @guards_dir end |
#include_default_guards ⇒ Boolean
Whether to include the default built-in guards (EnsurePresent, EnsurePositive).
57 58 59 |
# File 'lib/servus/config.rb', line 57 def include_default_guards @include_default_guards end |
#schemas_dir ⇒ String
The directory where JSON schema files are located.
Defaults to Rails.root/app/schemas/services in Rails applications.
23 24 25 |
# File 'lib/servus/config.rb', line 23 def schemas_dir @schemas_dir end |
#services_dir ⇒ String
The directory where services are located.
Defaults to Rails.root/app/services in Rails applications.
37 38 39 |
# File 'lib/servus/config.rb', line 37 def services_dir @services_dir end |
#strict_event_validation ⇒ Boolean
Whether to validate that all event handlers subscribe to events that are actually emitted by services.
When enabled, raises an error on boot if handlers subscribe to non-existent events. Helps catch typos and orphaned handlers.
45 46 47 |
# File 'lib/servus/config.rb', line 45 def strict_event_validation @strict_event_validation end |
Instance Method Details
#schema_dir_for(service_namespace) ⇒ String
Returns the directory containing a service's schema files.
93 94 95 |
# File 'lib/servus/config.rb', line 93 def schema_dir_for(service_namespace) File.join(root_path, schemas_dir, service_namespace) end |
#schema_path_for(service_namespace, type) ⇒ String
Returns the full path to a service's schema file.
81 82 83 |
# File 'lib/servus/config.rb', line 81 def schema_path_for(service_namespace, type) File.join(root_path, schemas_dir, service_namespace, "#{type}.json") end |