Class: Whoosh::Config
- Inherits:
-
Object
- Object
- Whoosh::Config
- Defined in:
- lib/whoosh/config.rb
Constant Summary collapse
- DEFAULTS =
{ "app" => { "name" => "Whoosh App", "env" => "development", "port" => 9292, "host" => "localhost" }, "server" => { "type" => "falcon", "workers" => "auto", "timeout" => 30 }, "logging" => { "level" => "info", "format" => "json" }, "docs" => { "enabled" => true }, "performance" => { "yjit" => true, "yjit_exec_mem" => 64 } }.freeze
- ENV_MAP =
{ "WHOOSH_PORT" => ["app", "port"], "WHOOSH_HOST" => ["app", "host"], "WHOOSH_ENV" => ["app", "env"], "WHOOSH_LOG_LEVEL" => ["logging", "level"], "WHOOSH_LOG_FORMAT" => ["logging", "format"] }.freeze
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#json_engine ⇒ Object
Returns the value of attribute json_engine.
Class Method Summary collapse
Instance Method Summary collapse
- #app_name ⇒ Object
- #development? ⇒ Boolean
- #docs_enabled? ⇒ Boolean
- #env ⇒ Object
- #host ⇒ Object
- #host=(value) ⇒ Object
-
#initialize(root:) ⇒ Config
constructor
A new instance of Config.
- #log_format ⇒ Object
- #log_level ⇒ Object
- #port ⇒ Object
- #port=(value) ⇒ Object
- #production? ⇒ Boolean
- #server_type ⇒ Object
- #shutdown_timeout ⇒ Object
- #test? ⇒ Boolean
Constructor Details
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
42 43 44 |
# File 'lib/whoosh/config.rb', line 42 def data @data end |
#json_engine ⇒ Object
Returns the value of attribute json_engine.
41 42 43 |
# File 'lib/whoosh/config.rb', line 41 def json_engine @json_engine end |
Class Method Details
.load(root:) ⇒ Object
44 45 46 |
# File 'lib/whoosh/config.rb', line 44 def self.load(root:) new(root: root) end |
Instance Method Details
#app_name ⇒ Object
77 78 79 |
# File 'lib/whoosh/config.rb', line 77 def app_name @data.dig("app", "name") end |
#development? ⇒ Boolean
101 102 103 |
# File 'lib/whoosh/config.rb', line 101 def development? env == "development" end |
#docs_enabled? ⇒ Boolean
93 94 95 |
# File 'lib/whoosh/config.rb', line 93 def docs_enabled? @data.dig("docs", "enabled") end |
#env ⇒ Object
73 74 75 |
# File 'lib/whoosh/config.rb', line 73 def env @data.dig("app", "env") end |
#host ⇒ Object
65 66 67 |
# File 'lib/whoosh/config.rb', line 65 def host @data.dig("app", "host") end |
#host=(value) ⇒ Object
69 70 71 |
# File 'lib/whoosh/config.rb', line 69 def host=(value) @data["app"]["host"] = value end |
#log_format ⇒ Object
89 90 91 |
# File 'lib/whoosh/config.rb', line 89 def log_format @data.dig("logging", "format") end |
#log_level ⇒ Object
85 86 87 |
# File 'lib/whoosh/config.rb', line 85 def log_level @data.dig("logging", "level") end |
#port ⇒ Object
57 58 59 |
# File 'lib/whoosh/config.rb', line 57 def port @data.dig("app", "port") end |
#port=(value) ⇒ Object
61 62 63 |
# File 'lib/whoosh/config.rb', line 61 def port=(value) @data["app"]["port"] = value.to_i end |
#production? ⇒ Boolean
105 106 107 |
# File 'lib/whoosh/config.rb', line 105 def production? env == "production" end |
#server_type ⇒ Object
81 82 83 |
# File 'lib/whoosh/config.rb', line 81 def server_type @data.dig("server", "type") end |
#shutdown_timeout ⇒ Object
97 98 99 |
# File 'lib/whoosh/config.rb', line 97 def shutdown_timeout @data.dig("server", "timeout") || 30 end |
#test? ⇒ Boolean
109 110 111 |
# File 'lib/whoosh/config.rb', line 109 def test? env == "test" end |