Class: Slamdown::Conversion::Configuration
- Inherits:
-
Object
- Object
- Slamdown::Conversion::Configuration
- Defined in:
- lib/slamdown/conversion/configuration.rb
Overview
Holds the complete validated conversion options relied upon by all later conversion stages.
Constant Summary collapse
- ATTRIBUTES =
[:inline, :headings, :entities, :html_indent, :urls, :tables, :elements, :classes, :ids].freeze
Class Method Summary collapse
-
.build(options = {}) ⇒ Object
Validates caller options and fills every omitted value from Slamdown's defaults.
Instance Method Summary collapse
-
#initialize(values) ⇒ Configuration
constructor
A new instance of Configuration.
-
#to_h ⇒ Object
Provides a plain immutable projection for consumers that need the complete effective configuration.
Constructor Details
#initialize(values) ⇒ Configuration
Returns a new instance of Configuration.
19 20 21 22 23 24 |
# File 'lib/slamdown/conversion/configuration.rb', line 19 def initialize(values) ATTRIBUTES.each do |attribute| instance_variable_set("@#{attribute}", Immutable.copy(values.fetch(attribute))) end freeze end |
Class Method Details
.build(options = {}) ⇒ Object
Validates caller options and fills every omitted value from Slamdown's defaults.
14 15 16 |
# File 'lib/slamdown/conversion/configuration.rb', line 14 def build( = {}) ConfigurationValidator.new().validate end |
Instance Method Details
#to_h ⇒ Object
Provides a plain immutable projection for consumers that need the complete effective configuration.
27 28 29 30 31 |
# File 'lib/slamdown/conversion/configuration.rb', line 27 def to_h ATTRIBUTES.each_with_object({}) do |attribute, result| result[attribute] = public_send(attribute) end.freeze end |