Class: LunchMoney::Configuration
- Inherits:
-
Object
- Object
- LunchMoney::Configuration
- Defined in:
- lib/lunchmoney/configuration.rb
Overview
Holds global configuration options for this gem
Instance Attribute Summary collapse
Instance Method Summary collapse
Constructor Details
#initialize ⇒ void
21 22 23 24 |
# File 'lib/lunchmoney/configuration.rb', line 21 def initialize @api_key = ENV.fetch("LUNCHMONEY_TOKEN", nil) @validate_object_attributes = T.let(true, T::Boolean) end |
Instance Attribute Details
#api_key ⇒ String?
15 16 17 |
# File 'lib/lunchmoney/configuration.rb', line 15 def api_key @api_key end |
#validate_object_attributes ⇒ Boolean
18 19 20 |
# File 'lib/lunchmoney/configuration.rb', line 18 def validate_object_attributes @validate_object_attributes end |
Instance Method Details
#valid? ⇒ Boolean
42 43 44 |
# File 'lib/lunchmoney/configuration.rb', line 42 def valid? validation_errors.empty? end |
#validation_errors ⇒ Array<String>
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/lunchmoney/configuration.rb', line 27 def validation_errors errors = [] if api_key&.strip&.empty? errors << "API key cannot be empty" end if api_key && T.must(api_key).length < 10 errors << "API key appears to be too short" end errors end |