Class: SPV::Options

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

Overview

Keeps options which are used to identify path to fixtures and options for a waiter which holds execution until expectation has been met.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Options

Returns a new instance of Options.



8
9
10
11
12
13
14
# File 'lib/site_prism_vcr/options.rb', line 8

def initialize(options = {})
  @shortcut_paths = {}

  options.each do |key, val|
    public_send("#{key}=", val)
  end
end

Instance Attribute Details

#shortcut_pathsObject

Returns the value of attribute shortcut_paths.



6
7
8
# File 'lib/site_prism_vcr/options.rb', line 6

def shortcut_paths
  @shortcut_paths
end

#waiterObject

Returns the value of attribute waiter.



6
7
8
# File 'lib/site_prism_vcr/options.rb', line 6

def waiter
  @waiter
end

#waiter_optionsHash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns options of a waiter in a hash format. If no options are defined, returns an empty hash.

Returns:

  • (Hash)


56
57
58
# File 'lib/site_prism_vcr/options.rb', line 56

def waiter_options
  @waiter_options
end

Instance Method Details

#add_shortcut_path(shortcut, path) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Defines shortcut path to fixtures.

Parameters:

  • shortcut (String)
  • path (String)

    Path to fixtures.



24
25
26
27
28
# File 'lib/site_prism_vcr/options.rb', line 24

def add_shortcut_path(shortcut, path)
  path << '/' unless path[-1, 1] == '/'

  self.shortcut_paths[shortcut] = path
end

#clone_optionsSPV::Options

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a copy of itself.

Returns:



46
47
48
# File 'lib/site_prism_vcr/options.rb', line 46

def clone_options
  dup
end

#merge_waiter_options!(options) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Merges already defined waiter’s options with a given hash.

If waiter’s options are not defined yet, it will define waiter options with a given hash.



68
69
70
# File 'lib/site_prism_vcr/options.rb', line 68

def merge_waiter_options!(options)
  self.waiter_options = self.waiter_options.merge(options)
end

#shortcut_path(shortcut) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a full path associated with a shortcut.

Parameters:

  • shortcut (String)

Returns:

  • (String)


37
38
39
# File 'lib/site_prism_vcr/options.rb', line 37

def shortcut_path(shortcut)
  self.shortcut_paths[shortcut]
end