lib/chronicle/etl/configurable.rb in chronicle-etl-0.4.1 vs lib/chronicle/etl/configurable.rb in chronicle-etl-0.4.2

- old
+ new

@@ -55,11 +55,11 @@ def apply_options(options) options.transform_keys!(&:to_sym) options.each do |name, value| setting = self.class.all_settings[name] - raise(Chronicle::ETL::ConfigurationError, "Unrecognized setting: #{name}") unless setting + raise(Chronicle::ETL::ConnectorConfigurationError, "Unrecognized setting: #{name}") unless setting @config[name] = coerced_value(setting, value) end validate_config options @@ -76,18 +76,23 @@ self.class.config_with_defaults end def validate_config missing = (self.class.all_required_settings.keys - @config.compacted_h.keys) - raise Chronicle::ETL::ConfigurationError, "Missing options: #{missing}" if missing.count.positive? + raise Chronicle::ETL::ConnectorConfigurationError, "Missing options: #{missing}" if missing.count.positive? end def coerced_value(setting, value) setting.type ? __send__("coerce_#{setting.type}", value) : value end def coerce_string(value) value.to_s + end + + # TODO: think about whether to split up float, integer + def coerce_numeric(value) + value.to_f end def coerce_boolean(value) if value.is_a?(String) value.downcase == "true"