Sha256: 0cd7d3da0b43dd8e599f878cb3a779066b8b7382846fc00cafcd61811137c7fd

Contents?: true

Size: 535 Bytes

Versions: 2

Compression:

Stored size: 535 Bytes

Contents

class Bogus::Interaction < Struct.new(:method, :args, :return_value, :error, :has_result)
  def initialize(method, args, &block)
    self.method = method
    self.args = args

    if block_given?
      evaluate_return_value(block)
      self.has_result = true
    end
  end

  def ==(other)
    return super(other) if has_result && other.has_result
    method == other.method && args == other.args
  end

  private

  def evaluate_return_value(block)
    self.return_value = block.call
  rescue => e
    self.error = e.class
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bogus-0.0.2 lib/bogus/interaction.rb
bogus-0.0.1 lib/bogus/interaction.rb