Class: Pretentious::RecordedProc
- Inherits:
-
Proc
- Object
- Proc
- Pretentious::RecordedProc
- Defined in:
- lib/pretentious/recorded_proc.rb
Instance Method Summary collapse
- #call(*args, &block) ⇒ Object
- #given_block? ⇒ Boolean
-
#initialize(target_proc, is_given_block = false) ⇒ RecordedProc
constructor
A new instance of RecordedProc.
- #is_called? ⇒ Boolean
- #return_value ⇒ Object
- #target_proc ⇒ Object
Constructor Details
#initialize(target_proc, is_given_block = false) ⇒ RecordedProc
Returns a new instance of RecordedProc.
5 6 7 8 9 10 11 |
# File 'lib/pretentious/recorded_proc.rb', line 5 def initialize(target_proc, is_given_block = false) @target_proc = target_proc @return_value = [] @args = [] @given_block = is_given_block @called = false end |
Instance Method Details
#call(*args, &block) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/pretentious/recorded_proc.rb', line 29 def call(*args, &block) @called = true @args << args return_value = @target_proc.call(*args, &block) unless @return_value.include? return_value @return_value << return_value end return_value end |
#given_block? ⇒ Boolean
13 14 15 |
# File 'lib/pretentious/recorded_proc.rb', line 13 def given_block? @given_block end |
#is_called? ⇒ Boolean
25 26 27 |
# File 'lib/pretentious/recorded_proc.rb', line 25 def is_called? @called end |
#return_value ⇒ Object
21 22 23 |
# File 'lib/pretentious/recorded_proc.rb', line 21 def return_value @return_value end |
#target_proc ⇒ Object
17 18 19 |
# File 'lib/pretentious/recorded_proc.rb', line 17 def target_proc @target_proc end |