Sha256: 738f321700c9aad358e75f5e16da0cc5f4455d3fc42b33dcc6b2ab2d09ea9781
Contents?: true
Size: 1.69 KB
Versions: 1
Compression:
Stored size: 1.69 KB
Contents
# frozen_string_literal: true require "sea_shanty/errors" require "sea_shanty/util/logger" module SeaShanty class Configuration attr_accessor :bypass, :readonly, :storage_dir alias_method :bypass?, :bypass alias_method :readonly?, :readonly def log=(destination) @logger = Logger.new(destination) end def logger @logger ||= Logger::NullLogger.new end 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sea_shanty-0.2.0 | lib/sea_shanty/configuration.rb |