lib/the_help/service.rb in the_help-1.3.2 vs lib/the_help/service.rb in the_help-1.4.0
- old
+ new
@@ -123,11 +123,11 @@
# Convenience method to instantiate the service and immediately call it
#
# Any arguments are passed to #initialize
def call(*args, &block)
result = new(*args).call(&block)
- return result if block_given?
+ return result unless result.is_a?(self)
self
end
# :nodoc:
def inherited(other)
@@ -198,10 +198,11 @@
log_service_call
main
self.block_result = yield result if block_given?
end
return block_result if block_given?
+ return result if result_set?
self
end
private
@@ -249,10 +250,14 @@
def stop!
throw :stop
end
def result
- raise TheHelp::NoResultError unless defined?(@result)
+ raise TheHelp::NoResultError unless result_set?
@result
+ end
+
+ def result_set?
+ defined?(@result)
end
end
end