Class: SPV::Fixtures::Handler

Inherits:
Object
  • Object
show all
Defined in:
lib/site_prism_vcr/fixtures/handler.rb

Overview

Prepares incoming raw list of fixtures to be used for inserting into VCR.

Applies a given list of modifiers to list of fixtures.

Instance Method Summary collapse

Constructor Details

#initialize(options, convertor = Converter) ⇒ Handler

Returns a new instance of Handler.



8
9
10
11
12
# File 'lib/site_prism_vcr/fixtures/handler.rb', line 8

def initialize(options, convertor = Converter)
  @options = options

  @converter = convertor
end

Instance Method Details

#handle_raw(raw_fixtures, modifiers) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/site_prism_vcr/fixtures/handler.rb', line 14

def handle_raw(raw_fixtures, modifiers)
  converted_fixtures = @converter.convert_raw(raw_fixtures)

  modifiers.map do |modifier|
    converted_fixtures.each do |converted_fixture|
      modifier.modify(converted_fixture)
    end
  end

  converted_fixtures
end

#handle_set_raws(*fixtures_set, modifiers) ⇒ Object



26
27
28
29
30
# File 'lib/site_prism_vcr/fixtures/handler.rb', line 26

def handle_set_raws(*fixtures_set, modifiers)
  fixtures_set.map do |fixtures_raw|
    handle_raw fixtures_raw, modifiers
  end
end