Class: SeaShanty::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/sea_shanty/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bypassObject Also known as: bypass?

Returns the value of attribute bypass.



8
9
10
# File 'lib/sea_shanty/configuration.rb', line 8

def bypass
  @bypass
end

#readonlyObject Also known as: readonly?

Returns the value of attribute readonly.



8
9
10
# File 'lib/sea_shanty/configuration.rb', line 8

def readonly
  @readonly
end

#storage_dirObject

Returns the value of attribute storage_dir.



8
9
10
# File 'lib/sea_shanty/configuration.rb', line 8

def storage_dir
  @storage_dir
end

Instance Method Details

#generic_responsesObject



33
34
35
# File 'lib/sea_shanty/configuration.rb', line 33

def generic_responses
  @generic_responses ||= {}
end

#generic_responses=(responses) ⇒ Object

Raises:



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/sea_shanty/configuration.rb', line 20

def generic_responses=(responses)
  unless Hash === responses
    raise(
      ConfigurationError,
      "Generic responses must be a hash that maps a Regexp or something else that responds to `match?` to a relative path to a file with a recorded response."
    )
  end

  raise ConfigurationError, "keys in the generic responses hash must respond to `match?`." unless responses.keys.all? { |key| key.respond_to?(:match?) }

  @generic_responses = responses
end

#log=(destination) ⇒ Object



12
13
14
# File 'lib/sea_shanty/configuration.rb', line 12

def log=(destination)
  @logger = Logger.new(destination)
end

#loggerObject



16
17
18
# File 'lib/sea_shanty/configuration.rb', line 16

def logger
  @logger ||= Logger::NullLogger.new
end

#request_body_filterObject



43
44
45
# File 'lib/sea_shanty/configuration.rb', line 43

def request_body_filter
  @request_body_filter ||= lambda { |body| body }
end

#request_body_filter=(filter) ⇒ Object

Raises:



37
38
39
40
41
# File 'lib/sea_shanty/configuration.rb', line 37

def request_body_filter=(filter)
  raise ConfigurationError, "Filter must have a call method" unless filter.respond_to?(:call)
  raise ConfigurationError, "Filter must have an arity of exactly 1" unless filter.arity == 1
  @request_body_filter = filter
end

#request_headers_filterObject



47
48
49
# File 'lib/sea_shanty/configuration.rb', line 47

def request_headers_filter
  @request_headers_filter ||= lambda { |key, value| value }
end

#request_headers_filter=(filter) ⇒ Object

Raises:



51
52
53
54
55
# File 'lib/sea_shanty/configuration.rb', line 51

def request_headers_filter=(filter)
  raise ConfigurationError, "Filter must have a call method" unless filter.respond_to?(:call)
  raise ConfigurationError, "Filter must have an arity of exactly 2" unless filter.arity == 2
  @request_headers_filter = filter
end