lib/dry/initializer/config.rb in dry-initializer-3.0.2 vs lib/dry/initializer/config.rb in dry-initializer-3.0.3
- old
+ new
@@ -76,10 +76,11 @@
# @return [Hash<Symbol, Object>]
def public_attributes(instance)
definitions.values.each_with_object({}) do |item, obj|
key = item.target
next unless instance.respond_to? key
+
val = instance.send(key)
obj[key] = val unless null == val
end
end
@@ -112,11 +113,11 @@
# Human-readable representation of configured params and options
# @return [String]
def inch
line = Builders::Signature[self]
- line = line.gsub("__dry_initializer_options__", "options")
+ line = line.gsub('__dry_initializer_options__', 'options')
lines = ["@!method initialize(#{line})"]
lines += ["Initializes an instance of #{extended_class}"]
lines += definitions.values.map(&:inch)
lines += ["@return [#{extended_class}]"]
lines.join("\n")
@@ -136,14 +137,14 @@
# rubocop: disable Metrics/MethodLength
def add_definition(option, name, type, block, **opts)
opts = {
parent: extended_class,
option: option,
- null: null,
+ null: null,
source: name,
- type: type,
- block: block,
+ type: type,
+ block: block,
**opts
}
options = Dispatchers.call(**opts)
definition = Definition.new(**options)
@@ -161,9 +162,10 @@
end
def check_type(previous, current)
return current unless previous
return current if previous.option == current.option
+
raise SyntaxError,
"cannot reload #{previous} of #{extended_class.superclass}" \
" by #{current} of its subclass #{extended_class}"
end