class Pretentious::RecordedProc

Sublass of Proc that records whatever was passed to it and whatever it returns

Attributes

return_value[R]
target_proc[R]

Public Class Methods

new(target_proc, is_given_block = false) click to toggle source
# File lib/pretentious/recorded_proc.rb, line 6
def initialize(target_proc, is_given_block = false)
  @target_proc = target_proc
  @return_value = []
  @args = []
  @given_block = is_given_block
  @called = false
end

Public Instance Methods

call(*args, &block) click to toggle source
# File lib/pretentious/recorded_proc.rb, line 22
def call(*args, &block)
  @called = true
  @args << args
  return_value = @target_proc.call(*args, &block)

  @return_value << return_value unless @return_value.include? return_value
  return_value
end
given_block?() click to toggle source
# File lib/pretentious/recorded_proc.rb, line 14
def given_block?
  @given_block
end
is_called?() click to toggle source
# File lib/pretentious/recorded_proc.rb, line 18
def is_called?
  @called
end