Module: Chronicle::ETL::Configurable::ClassMethods
- Defined in:
- lib/chronicle/etl/configurable.rb
Overview
Class methods for classes that have Configurable mixed in
Instance Method Summary collapse
-
#all_required_settings ⇒ Object
Filters settings to those that are required.
-
#all_settings ⇒ Object
Collect all settings defined on this class and its ancestors (that have Configurable mixin included).
- #config_with_defaults ⇒ Object
-
#setting(name, default: nil, required: false, type: nil, description: nil) ⇒ Object
Macro for creating a setting on a class Chronicle::ETL::Configurable.
- #setting_exists?(name) ⇒ Boolean
- #settings ⇒ Object
Instance Method Details
#all_required_settings ⇒ Object
Filters settings to those that are required.
168 169 170 |
# File 'lib/chronicle/etl/configurable.rb', line 168 def all_required_settings all_settings.select { |_name, setting| setting.required } || {} end |
#all_settings ⇒ Object
Collect all settings defined on this class and its ancestors (that have Configurable mixin included)
159 160 161 162 163 164 165 |
# File 'lib/chronicle/etl/configurable.rb', line 159 def all_settings if superclass.include?(Chronicle::ETL::Configurable) superclass.all_settings.merge(settings) else settings end end |
#config_with_defaults ⇒ Object
180 181 182 183 |
# File 'lib/chronicle/etl/configurable.rb', line 180 def config_with_defaults s = all_settings.transform_values(&:default) Config.new(s) end |
#setting(name, default: nil, required: false, type: nil, description: nil) ⇒ Object
Macro for creating a setting on a class Chronicle::ETL::Configurable
152 153 154 155 |
# File 'lib/chronicle/etl/configurable.rb', line 152 def setting(name, default: nil, required: false, type: nil, description: nil) s = Setting.new(default, required, type, description) settings[name] = s end |
#setting_exists?(name) ⇒ Boolean
176 177 178 |
# File 'lib/chronicle/etl/configurable.rb', line 176 def setting_exists?(name) all_settings.keys.include? name end |
#settings ⇒ Object
172 173 174 |
# File 'lib/chronicle/etl/configurable.rb', line 172 def settings @settings ||= {} end |