lib/caricature/clr/messenger.rb in caricature-0.6.3 vs lib/caricature/clr/messenger.rb in caricature-0.7.0

- old
+ new

@@ -4,42 +4,37 @@ class ClrClassMessenger < Messenger protected # deliver the message to the receiving isolation - def internal_deliver(mode, method_name, return_type, *args, &b) - exp = expectations.find(method_name, mode, *args) + def internal_deliver(mode, method_name, return_type, *args, &b) + exp = expectations.find(method_name, mode, *args) + is_value_type = return_type && return_type != System::Void.to_clr_type && return_type.is_value_type + res = nil if exp res = instance.__send__(method_name, *args, &b) if exp.super_before? res = exp.execute *args res = instance.__send__(method_name, *args, &b) if !exp.super_before? and exp.call_super? - res - else - rt = nil - is_value_type = return_type && return_type != System::Void.to_clr_type && return_type.is_value_type - rt = System::Activator.create_instance(return_type) if is_value_type - rt end + res ||= System::Activator.create_instance(return_type) if is_value_type + res end end # Encapsulates sending messages to CLR interface isolations class ClrInterfaceMessenger < Messenger protected # deliver the message to the receiving isolation - def internal_deliver(mode, method_name, return_type, *args, &b) + def internal_deliver(mode, method_name, return_type, *args, &b) + res = nil + is_value_type = return_type && return_type != System::Void.to_clr_type && return_type.is_value_type exp = expectations.find(method_name, mode, *args) - if exp - res = exp.execute *args - res - else - rt = nil - rt = System::Activator.create_instance(return_type) if return_type && return_type != System::Void.to_clr_type && return_type.is_value_type - rt - end + res = exp.execute *args if exp + res ||= System::Activator.create_instance(return_type) if is_value_type + res end end end \ No newline at end of file