Class: Solidstats::Configuration
- Inherits:
-
Object
- Object
- Solidstats::Configuration
- Defined in:
- lib/solidstats.rb
Overview
Configuration class for Solidstats gem
Instance Attribute Summary collapse
-
#assets ⇒ Hash
Asset configuration options.
-
#cache_duration ⇒ ActiveSupport::Duration
Cache duration for services.
-
#css_framework ⇒ Symbol
CSS framework integration (:none, :bootstrap, :tailwind).
-
#enable_components ⇒ Boolean
Whether to enable ViewComponent integration.
-
#enable_previews ⇒ Boolean
Whether to enable component previews.
-
#log_level ⇒ Symbol
Logging level.
-
#preview_layout ⇒ String
Layout for component previews.
Instance Method Summary collapse
-
#components_enabled? ⇒ Boolean
Check if components are enabled and available.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#previews_enabled? ⇒ Boolean
Check if previews are enabled.
-
#validate! ⇒ Boolean
Validate configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
253 254 255 |
# File 'lib/solidstats.rb', line 253 def initialize set_defaults end |
Instance Attribute Details
#assets ⇒ Hash
Returns Asset configuration options.
247 248 249 |
# File 'lib/solidstats.rb', line 247 def assets @assets end |
#cache_duration ⇒ ActiveSupport::Duration
Returns Cache duration for services.
227 228 229 |
# File 'lib/solidstats.rb', line 227 def cache_duration @cache_duration end |
#css_framework ⇒ Symbol
Returns CSS framework integration (:none, :bootstrap, :tailwind).
251 252 253 |
# File 'lib/solidstats.rb', line 251 def css_framework @css_framework end |
#enable_components ⇒ Boolean
Returns Whether to enable ViewComponent integration.
231 232 233 |
# File 'lib/solidstats.rb', line 231 def enable_components @enable_components end |
#enable_previews ⇒ Boolean
Returns Whether to enable component previews.
239 240 241 |
# File 'lib/solidstats.rb', line 239 def enable_previews @enable_previews end |
#log_level ⇒ Symbol
Returns Logging level.
235 236 237 |
# File 'lib/solidstats.rb', line 235 def log_level @log_level end |
#preview_layout ⇒ String
Returns Layout for component previews.
243 244 245 |
# File 'lib/solidstats.rb', line 243 def preview_layout @preview_layout end |
Instance Method Details
#components_enabled? ⇒ Boolean
Check if components are enabled and available
259 260 261 |
# File 'lib/solidstats.rb', line 259 def components_enabled? @enable_components && Solidstats.view_component_available? end |
#previews_enabled? ⇒ Boolean
Check if previews are enabled
265 266 267 |
# File 'lib/solidstats.rb', line 265 def previews_enabled? @enable_previews && Solidstats.development? end |
#validate! ⇒ Boolean
Validate configuration
272 273 274 275 276 277 278 279 280 281 282 |
# File 'lib/solidstats.rb', line 272 def validate! unless cache_duration.respond_to?(:seconds) raise ConfigurationError, "cache_duration must be a time duration" end unless [ :debug, :info, :warn, :error, :fatal, :unknown ].include?(@log_level) raise ConfigurationError, "log_level must be a valid log level symbol" end true end |