Sha256: 75366a41ff7321fd65dafab873b885a42029e797e1867e0cb7bffcaccc2fb6c9

Contents?: true

Size: 473 Bytes

Versions: 2

Compression:

Stored size: 473 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
    @object.errors[:memento_undo]
  end
  
  def failed?
    !!error
  end
  
  def success?
    !failed?
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
yolk-memento-0.2.0 lib/memento/result.rb
memento-0.3.0 lib/memento/result.rb