Sha256: 93918f20c0a3f077539776212f1ec5e2a1568ad7b3907ecbfacc7536a47b8d2b

Contents?: true

Size: 550 Bytes

Versions: 2

Compression:

Stored size: 550 Bytes

Contents

module Memento
  class ResultArray < Array
    def errors
      self.find_all{ |result| result.failed? }
    end

    def failed?
      self.any?{ |result| result.failed? }
    end

    def success?
      !failed?
    end

  end

  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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
memento-0.4.1 lib/memento/result.rb
memento-0.4.0 lib/memento/result.rb