Module: Mimic::Recorder
- Included in:
- Controls::Recorder::Example
- Defined in:
- lib/mimic/recorder.rb
Instance Attribute Summary collapse
- #__records ⇒ Object (also: #records)
Instance Method Summary collapse
- #__invocation(method_name, &blk) ⇒ Object (also: #invocation)
- #__invocations(method_name = nil, &blk) ⇒ Object (also: #invocations)
- #__invoked?(method_name, &blk) ⇒ Boolean (also: #invoked?)
- #__record(invocation) ⇒ Object (also: #record)
Instance Attribute Details
#__records ⇒ Object Also known as: records
4 5 6 |
# File 'lib/mimic/recorder.rb', line 4 def __records @__records ||= [] end |
Instance Method Details
#__invocation(method_name, &blk) ⇒ Object Also known as: invocation
15 16 17 18 19 20 21 22 23 |
# 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 |
#__invocations(method_name = nil, &blk) ⇒ Object Also known as: invocations
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# 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 |
#__invoked?(method_name, &blk) ⇒ Boolean Also known as: invoked?
47 48 49 50 |
# File 'lib/mimic/recorder.rb', line 47 def __invoked?(method_name, &blk) invocation = __invocation(method_name, &blk) !invocation.nil? end |
#__record(invocation) ⇒ Object Also known as: record
10 11 12 |
# File 'lib/mimic/recorder.rb', line 10 def __record(invocation) __records << invocation end |