Sha256: 1903de5b79bb947f7454791c741cd40050376c30cc181af16b69cc6da8e28c61

Contents?: true

Size: 540 Bytes

Versions: 5

Compression:

Stored size: 540 Bytes

Contents

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

    def failed?
      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

5 entries across 5 versions & 1 rubygems

Version Path
memento-0.5.2 lib/memento/result.rb
memento-0.5.1 lib/memento/result.rb
memento-0.5.0 lib/memento/result.rb
memento-0.4.3 lib/memento/result.rb
memento-0.4.2 lib/memento/result.rb