lib/memento/result.rb in memento-0.3.7 vs lib/memento/result.rb in memento-0.4.0

- old
+ new

@@ -1,37 +1,38 @@ -class Memento::ResultArray < Array - - def errors - self.find_all{ |result| result.failed? } - end - - def failed? - self.any?{ |result| result.failed? } - end - - def success? - !failed? - end - -end +module Memento + class ResultArray < Array + def errors + self.find_all{ |result| result.failed? } + end -class Memento::Result - - attr_reader :object, :state - - def initialize(object, state) - @object, @state = object, state + def failed? + self.any?{ |result| result.failed? } + end + + def success? + !failed? + end + end - - def error - error = @object.errors[:memento_undo] - error.present? ? error : nil - end - - def failed? - !!error - end - - def success? - !failed? + + class Result + + attr_reader :object, :state + + def initialize(object, state) + @object, @state = object, state + end + + def error + error = @object.errors[:memento_undo] + error.present? ? error : nil + end + + def failed? + !!error + end + + def success? + !failed? + end end end \ No newline at end of file