Sha256: b49bc4e353d5c5ff4a37efe8220f333d00390c414601fcb8366741027bdbff86

Contents?: true

Size: 514 Bytes

Versions: 7

Compression:

Stored size: 514 Bytes

Contents

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

class Memento::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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
memento-0.3.7 lib/memento/result.rb
memento-0.3.6 lib/memento/result.rb
memento-0.3.5 lib/memento/result.rb
memento-0.3.4 lib/memento/result.rb
memento-0.3.3 lib/memento/result.rb
memento-0.3.2 lib/memento/result.rb
memento-0.3.1 lib/memento/result.rb