Module: PaintbrushSupport::Configuration
- Defined in:
- lib/paintbrush_support/configuration.rb
Overview
Provides a configuration interface for Paintbrush features, allows disabling colorization.
Usage:
“‘ruby Paintbrush::Configuration.colorize = false “`
Class Attribute Summary collapse
-
.configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
.defaults ⇒ Object
readonly
Returns the value of attribute defaults.
Class Method Summary collapse
- .colorize=(val) ⇒ Object
- .colorize? ⇒ Boolean
- .reset ⇒ Object
- .with_configuration(**options, &block) ⇒ Object
Class Attribute Details
.configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
19 20 21 |
# File 'lib/paintbrush_support/configuration.rb', line 19 def configuration @configuration end |
.defaults ⇒ Object (readonly)
Returns the value of attribute defaults.
19 20 21 |
# File 'lib/paintbrush_support/configuration.rb', line 19 def defaults @defaults end |
Class Method Details
.colorize=(val) ⇒ Object
21 22 23 |
# File 'lib/paintbrush_support/configuration.rb', line 21 def colorize=(val) configuration[:colorize] = val end |
.colorize? ⇒ Boolean
25 26 27 |
# File 'lib/paintbrush_support/configuration.rb', line 25 def colorize? configuration.fetch(:colorize, defaults[:colorize]) end |
.reset ⇒ Object
29 30 31 |
# File 'lib/paintbrush_support/configuration.rb', line 29 def reset @configuration = {} end |
.with_configuration(**options, &block) ⇒ Object
33 34 35 36 37 |
# File 'lib/paintbrush_support/configuration.rb', line 33 def with_configuration(**, &block) previous = configuration.dup .compact.each { |key, value| configuration[key] = value unless configuration.key?(key) } block.call.tap { @configuration = previous } end |