Class: Adalog::Configuration
- Inherits:
-
Object
- Object
- Adalog::Configuration
- Defined in:
- lib/adalog/configuration.rb
Constant Summary collapse
- RequiredSettings =
[:repo, :singleton, :html_erb, :time_format, :web_heading].freeze
- UntouchedValue =
Object.new.freeze
Instance Method Summary collapse
- #defaults ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #validate! ⇒ Object
- #web_defaults ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
10 11 12 13 14 |
# File 'lib/adalog/configuration.rb', line 10 def initialize defaults.each_pair do |attr, value| self.send("#{attr}=", value) end end |
Instance Method Details
#defaults ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/adalog/configuration.rb', line 17 def defaults { repo: Adalog::InMemoryRepo.new, singleton: true, html_erb: true, time_format: "%H:%M:%S - %d %b %Y", web_heading: "Stub Adapter Logs", } end |
#validate! ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/adalog/configuration.rb', line 35 def validate! RequiredSettings.each do |required_attr| if UntouchedValue == self.send(required_attr) raise "Setting '#{required_attr}' for Adalog left unconfigured." end end end |
#web_defaults ⇒ Object
27 28 29 30 31 32 |
# File 'lib/adalog/configuration.rb', line 27 def web_defaults { repo: self.repo, time_format: self.time_format, heading: self.web_heading, } end |