Class: VCR::LinkedCassette::CassetteList

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/vcr/linked_cassette.rb

Overview

An enumerable lazily wrapping a list of cassettes that a context is using

Instance Method Summary collapse

Constructor Details

#initialize(cassettes, linked_cassettes) ⇒ CassetteList

Creates a new list of context-owned cassettes and linked cassettes

Parameters:

  • cassettes (Array)

    context-owned cassettes

  • linked_cassettes (Array)

    context-unowned (linked) cassettes


14
15
16
17
# File 'lib/vcr/linked_cassette.rb', line 14

def initialize(cassettes, linked_cassettes)
  @cassettes = cassettes
  @linked_cassettes = linked_cassettes
end

Instance Method Details

#eachObject

Yields linked cassettes first, and then context-owned cassettes


20
21
22
23
24
25
26
27
28
# File 'lib/vcr/linked_cassette.rb', line 20

def each
  @linked_cassettes.each do |cassette|
    yield wrap(cassette)
  end

  @cassettes.each do |cassette|
    yield cassette
  end
end

#lastObject

Provide last implementation, which is not provided by Enumerable


31
32
33
34
35
36
37
# File 'lib/vcr/linked_cassette.rb', line 31

def last
  cassette = @cassettes.last
  return cassette if cassette

  cassette = @linked_cassettes.last
  wrap(cassette) if cassette
end

#sizeObject

Provide size implementation, which is not provided by Enumerable


40
41
42
# File 'lib/vcr/linked_cassette.rb', line 40

def size
  @cassettes.size + @linked_cassettes.size
end