lib/rice_bubble/attributes/object.rb in rice_bubble-0.1.2 vs lib/rice_bubble/attributes/object.rb in rice_bubble-0.2.0

- old
+ new

@@ -14,19 +14,14 @@ children.all? do |name, attr| attr.valid?(value[name]) end end - def validate!(value, path:, **) - children.each do |name, attr| - child = attr.fetch(value, name) - coerced = attr.coerce(child) - attr.validate!(child, coerced:, path: "#{path}.#{name}") + def call(value, path: '') + children.to_h do |name, attr| + [name, + attr.call(value[name] || value[name.to_s], path: "#{path}.#{name}")] end - end - - def coerce(value) - children.map { |name, attr| attr.coerce(attr.fetch(value, name)) } end end end end