lib/dao/api/modes.rb in dao-2.0.0 vs lib/dao/api/modes.rb in dao-2.1.0
- old
+ new
@@ -17,11 +17,18 @@
module_eval(<<-__, __FILE__, __LINE__ - 1)
def #{ mode }(*args, &block)
if args.empty?
- mode(#{ mode.inspect }, &block)
+ if catching_results?
+ if self.mode == #{ mode.inspect }
+ mode(#{ mode.inspect }, &block)
+ return!
+ end
+ else
+ mode(#{ mode.inspect }, &block)
+ end
else
mode(#{ mode.inspect }) do
call(*args, &block)
end
end
@@ -66,14 +73,10 @@
condition = self.mode == mode
if block.nil?
condition
else
- if condition
- result = block.call
- throw(:result, result) if catching_the_result?
- result
- end
+ send(mode, &block) if condition
end
end
end
Api.modes = Mode.list