timriley on v0.24.0
timriley on remove-dry-struct
github-actions[bot] on main
[devtools] sync (compare)
action-hero[bot] on main
Update dry-system.gemspec from … (compare)
flash-gordon on main
Remove dry-struct dependency I… Bump version Update CHANGELOG (compare)
Foo.new
in 90% of the cases
class FormAttributes < Dry::Data::Struct
def self.new(attributes)
schema_defaults = schema.keys.map { |key| [key, nil] }.to_h
super(schema_defaults.merge(Hash(attributes)))
end
def [](attribute_name)
send(attribute_name)
end
end
#[]
in place so I can use it with a ROM::Model::Validator
App.register "transformations.to_h" do |input|
input.to_h
end
App.register("transactions.sign_up_customer") do
CallSheet(container: App) do
map :process, with: "attributes.customer_sign_up"
try :validate, with: "validators.customer", catch: ROM::Model::ValidationError
map :prepare_for_persist, with: "transformations.to_h"
tee :persist, with: "persistence.commands.create_customer"
end
end
Added a #to_h
to that FormAttributes
class and that prepare_for_persist
step in the business transaction.