lib/micro/case.rb in u-case-4.1.1 vs lib/micro/case.rb in u-case-4.2.0

- old
+ new

@@ -241,9 +241,23 @@ def __get_result(is_success, value, type) @__result.__set__(is_success, value, type, self) end + def transaction(adapter = :activerecord) + raise NotImplementedError unless adapter == :activerecord + + result = nil + + ActiveRecord::Base.transaction do + result = yield + + raise ActiveRecord::Rollback if result.failure? + end + + result + end + private_constant :MapFailureType, :INVALID_INVOCATION_OF_THE_THEN_METHOD end def self.case?(arg) arg.is_a?(Class) && arg < Case