Class: SPV::Fixtures
- Inherits:
-
Object
show all
- Includes:
- Enumerable
- Defined in:
- lib/site_prism_vcr/fixtures.rb,
lib/site_prism_vcr/fixtures/handler.rb,
lib/site_prism_vcr/fixtures/manager.rb,
lib/site_prism_vcr/fixtures/converter.rb,
lib/site_prism_vcr/fixtures/tmp_keeper.rb,
lib/site_prism_vcr/fixtures/modifiers/base.rb,
lib/site_prism_vcr/fixtures/modifiers/path.rb,
lib/site_prism_vcr/fixtures/modifiers/relative_path.rb,
lib/site_prism_vcr/fixtures/modifiers/shortcut_path.rb
Overview
Converts list with fixture names into list of SPV::Fixture objects.
Defined Under Namespace
Modules: Modifiers
Classes: Converter, Handler, Manager, TmpKeeper
Instance Method Summary
collapse
Constructor Details
#initialize(vals) ⇒ Fixtures
Returns a new instance of Fixtures.
7
8
9
10
11
|
# File 'lib/site_prism_vcr/fixtures.rb', line 7
def initialize(vals)
@container = vals.each_with_object({}) do |fixture, memo|
memo[fixture.name] = fixture
end
end
|
Instance Method Details
#each(&block) ⇒ Object
33
34
35
|
# File 'lib/site_prism_vcr/fixtures.rb', line 33
def each(&block)
@container.values.each &block
end
|
#exchange(old_vals, new_vals) ⇒ Object
13
14
15
16
17
18
19
|
# File 'lib/site_prism_vcr/fixtures.rb', line 13
def exchange(old_vals, new_vals)
new_list = self.each_with_object([]) do |item, memo|
memo << item unless old_vals.any? {|old_item| item.name == old_item.name }
end
self.class.new(new_list.concat(new_vals))
end
|
#replace(vals) ⇒ Object
21
22
23
24
25
26
27
|
# File 'lib/site_prism_vcr/fixtures.rb', line 21
def replace(vals)
if vals.length > 0
self.class.new(vals)
else
self
end
end
|
#size ⇒ Object
37
38
39
|
# File 'lib/site_prism_vcr/fixtures.rb', line 37
def size
@container.values
end
|
#union(vals) ⇒ Object
29
30
31
|
# File 'lib/site_prism_vcr/fixtures.rb', line 29
def union(vals)
self.class.new(@container.values.concat(vals))
end
|