module Mimic::Recorder

Attributes

__records[W]
records=[W]

Public Instance Methods

__invocation(method_name, &blk) click to toggle source
# File lib/mimic/recorder.rb, line 15
def __invocation(method_name, &blk)
  invocations = __invocations(method_name, &blk)

  if invocations.empty?
    return nil
  end

  return invocations.first
end
Also aliased as: invocation
__invocations(method_name=nil, &blk) click to toggle source
# File lib/mimic/recorder.rb, line 26
def __invocations(method_name=nil, &blk)
  if method_name.nil? && blk.nil?
    return __records
  end

  invocations = __records.select { |invocation| invocation.method_name == method_name }

  if blk.nil?
    return invocations
  end

  if invocations.empty?
    return []
  end

  invocations.select do |invocation|
    invocation.parameters.find { |k, v| blk.(k, v)}
  end
end
Also aliased as: invocations
__invoked?(method_name, &blk) click to toggle source
# File lib/mimic/recorder.rb, line 47
def __invoked?(method_name, &blk)
  invocation = __invocation(method_name, &blk)
  !invocation.nil?
end
Also aliased as: invoked?
__record(invocation) click to toggle source
# File lib/mimic/recorder.rb, line 10
def __record(invocation)
  __records << invocation
end
Also aliased as: record
__records() click to toggle source
# File lib/mimic/recorder.rb, line 4
def __records
  @__records ||= []
end
Also aliased as: records
invocation(method_name, &blk)
Alias for: __invocation
invocations(method_name=nil, &blk)
Alias for: __invocations
invoked?(method_name, &blk)
Alias for: __invoked?
record(invocation)
Alias for: __record
records()
Alias for: __records