Sha256: d3731604260afabe682efe166806e9d44a9b840e0e205cc7da3ae1c19184b67b
Contents?: true
Size: 1.52 KB
Versions: 2
Compression:
Stored size: 1.52 KB
Contents
# frozen_string_literal: true require "sea_shanty/errors" module SeaShanty class Configuration attr_accessor :bypass, :readonly, :storage_dir alias_method :bypass?, :bypass alias_method :readonly?, :readonly 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 def generic_responses @generic_responses ||= {} end 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 def request_body_filter @request_body_filter ||= lambda { |body| body } end def request_headers_filter @request_headers_filter ||= lambda { |key, value| value } end 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 end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sea_shanty-0.1.1 | lib/sea_shanty/configuration.rb |
sea_shanty-0.1.0 | lib/sea_shanty/configuration.rb |