lib/shamu/services/request.rb in shamu-0.0.21 vs lib/shamu/services/request.rb in shamu-0.0.24

- old
+ new

@@ -83,9 +83,21 @@ end @on_complete_blocks && @on_complete_blocks.each( &:call ) end + # Adds an error to {#errors} and returns self. Used when performing an + # early return in a service method + # + # @example + # next request.error( :title, "should be clever" ) unless title_is_clever? + # + # @return [self] + def error( *args ) + errors.add( *args ) + self + end + class << self # Coerces a hash or params object to a proper {Request} object. # @param [Object] params to be coerced. # @return [Request] the coerced request. def coerce( params )