lib/shamu/services/request_support.rb in shamu-0.0.17 vs lib/shamu/services/request_support.rb in shamu-0.0.18

- old
+ new

@@ -68,14 +68,14 @@ # # All good, return an entity for the order # scorpion.fetch OrderEntity, { order: order }, {} # end # end def with_request( params, request_class, &block ) - with_partial_request params, request_class do |request| + with_partial_request params, request_class do |request, *args| next unless request.valid? - yield request + yield request, *args end end # @!visibility public # @@ -88,18 +88,13 @@ # @see #with_request def with_partial_request( params, request_class, &block ) request = request_class.coerce( params ) sources = yield( request ) - # Make sure the request captures errors even if the block doesn't - # check - request.valid? + result = Result.coerce( sources, request: request ) + request.run_callbacks( result.valid? ) - if sources.is_a?( Result ) - sources - else - result( *Array.wrap( sources ), request: request ) - end + result end # Static methods added to {RequestSupport} class_methods do