Class: Takagi::Config
- Inherits:
-
Object
- Object
- Takagi::Config
- Defined in:
- lib/takagi/config.rb
Overview
Stores runtime configuration loaded from YAML or manual overrides.
Defined Under Namespace
Classes: AllocationConfig, EventBusConfig, MiddlewareConfig, Observability, PluginConfig, RouterConfig
Instance Attribute Summary collapse
-
#allocation ⇒ Object
Returns the value of attribute allocation.
-
#auto_migrate ⇒ Object
Returns the value of attribute auto_migrate.
-
#bind_address ⇒ Object
Returns the value of attribute bind_address.
-
#custom ⇒ Object
Returns the value of attribute custom.
-
#event_bus ⇒ Object
Returns the value of attribute event_bus.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#middleware ⇒ Object
Returns the value of attribute middleware.
-
#observability ⇒ Object
Returns the value of attribute observability.
-
#plugins ⇒ Object
Returns the value of attribute plugins.
-
#port ⇒ Object
Returns the value of attribute port.
-
#processes ⇒ Object
Returns the value of attribute processes.
-
#protocols ⇒ Object
Returns the value of attribute protocols.
-
#router ⇒ Object
Returns the value of attribute router.
-
#server_name ⇒ Object
Returns the value of attribute server_name.
-
#threads ⇒ Object
Returns the value of attribute threads.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #load_file(path) ⇒ Object
- #method_missing(name, *args, &block) ⇒ Object
- #respond_to_missing?(name, include_private = false) ⇒ Boolean
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/takagi/config.rb', line 24 def initialize set_server_defaults set_observability_defaults set_event_bus_defaults set_router_defaults set_middleware_defaults set_allocation_defaults set_plugin_defaults @custom = {} @server_name = nil end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/takagi/config.rb', line 44 def method_missing(name, *args, &block) key = name.to_s.chomp('=').to_sym if name.to_s.end_with?('=') @custom[key] = args.first elsif @custom.key?(key) @custom[key] else super(&block) end end |
Instance Attribute Details
#allocation ⇒ Object
Returns the value of attribute allocation.
21 22 23 |
# File 'lib/takagi/config.rb', line 21 def allocation @allocation end |
#auto_migrate ⇒ Object
Returns the value of attribute auto_migrate.
21 22 23 |
# File 'lib/takagi/config.rb', line 21 def auto_migrate @auto_migrate end |
#bind_address ⇒ Object
Returns the value of attribute bind_address.
21 22 23 |
# File 'lib/takagi/config.rb', line 21 def bind_address @bind_address end |
#custom ⇒ Object
Returns the value of attribute custom.
21 22 23 |
# File 'lib/takagi/config.rb', line 21 def custom @custom end |
#event_bus ⇒ Object
Returns the value of attribute event_bus.
21 22 23 |
# File 'lib/takagi/config.rb', line 21 def event_bus @event_bus end |
#logger ⇒ Object
Returns the value of attribute logger.
21 22 23 |
# File 'lib/takagi/config.rb', line 21 def logger @logger end |
#middleware ⇒ Object
Returns the value of attribute middleware.
21 22 23 |
# File 'lib/takagi/config.rb', line 21 def middleware @middleware end |
#observability ⇒ Object
Returns the value of attribute observability.
21 22 23 |
# File 'lib/takagi/config.rb', line 21 def observability @observability end |
#plugins ⇒ Object
Returns the value of attribute plugins.
21 22 23 |
# File 'lib/takagi/config.rb', line 21 def plugins @plugins end |
#port ⇒ Object
Returns the value of attribute port.
21 22 23 |
# File 'lib/takagi/config.rb', line 21 def port @port end |
#processes ⇒ Object
Returns the value of attribute processes.
21 22 23 |
# File 'lib/takagi/config.rb', line 21 def processes @processes end |
#protocols ⇒ Object
Returns the value of attribute protocols.
21 22 23 |
# File 'lib/takagi/config.rb', line 21 def protocols @protocols end |
#router ⇒ Object
Returns the value of attribute router.
21 22 23 |
# File 'lib/takagi/config.rb', line 21 def router @router end |
#server_name ⇒ Object
Returns the value of attribute server_name.
21 22 23 |
# File 'lib/takagi/config.rb', line 21 def server_name @server_name end |
#threads ⇒ Object
Returns the value of attribute threads.
21 22 23 |
# File 'lib/takagi/config.rb', line 21 def threads @threads end |
Instance Method Details
#[](key) ⇒ Object
36 37 38 |
# File 'lib/takagi/config.rb', line 36 def [](key) @custom[key.to_sym] end |
#[]=(key, value) ⇒ Object
40 41 42 |
# File 'lib/takagi/config.rb', line 40 def []=(key, value) @custom[key.to_sym] = value end |
#load_file(path) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/takagi/config.rb', line 60 def load_file(path) data = load_yaml(path) apply_basic_settings(data) apply_logger(data) apply_observability(data) apply_event_bus(data) apply_router(data) apply_middleware(data) apply_allocation(data) apply_plugins(data) apply_custom_settings(data) end |
#respond_to_missing?(name, include_private = false) ⇒ Boolean
55 56 57 58 |
# File 'lib/takagi/config.rb', line 55 def respond_to_missing?(name, include_private = false) key = name.to_s.chomp('=').to_sym @custom.key?(key) || super end |