Class: TryUntil::Probe

Inherits:
Object
  • Object
show all
Defined in:
lib/try_until/probe.rb

Overview

This PORO holds information about a target object against which to call a specified method with specified arguments

Instance Method Summary collapse

Constructor Details

#initialize(target, method, args = []) ⇒ Probe

Example: Probe.new(SomeClass.new, :some_method, [arg1, arg2, …])



7
8
9
10
11
# File 'lib/try_until/probe.rb', line 7

def initialize(target, method, args = [])
  @target = target
  @method = method
  @args = args
end

Instance Method Details

#sampleObject



13
14
15
16
17
18
19
# File 'lib/try_until/probe.rb', line 13

def sample
  if args_is_one_hash?
    @target.send(@method, @args)
  else
    @target.send(@method, *@args)
  end
end

#to_sObject



21
22
23
# File 'lib/try_until/probe.rb', line 21

def to_s
  "Probe: #{@target.class}##{@method}(#{@args})"
end