Class: WebValve::FakeServiceConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/webvalve/fake_service_config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(service:, url: nil) ⇒ FakeServiceConfig

Returns a new instance of FakeServiceConfig.



5
6
7
8
# File 'lib/webvalve/fake_service_config.rb', line 5

def initialize(service:, url: nil)
  @service = service
  @custom_service_url = url
end

Instance Attribute Details

#serviceObject (readonly)

Returns the value of attribute service.



3
4
5
# File 'lib/webvalve/fake_service_config.rb', line 3

def service
  @service
end

Instance Method Details

#service_urlObject



15
16
17
18
19
20
21
# File 'lib/webvalve/fake_service_config.rb', line 15

def service_url
  @service_url ||= begin
    url = custom_service_url || default_service_url
    raise missing_url_message if url.blank?
    strip_basic_auth url
  end
end

#should_intercept?Boolean

Returns:

  • (Boolean)


10
11
12
13
# File 'lib/webvalve/fake_service_config.rb', line 10

def should_intercept?
  WebValve.env.test? || # always intercept in test
    (WebValve.enabled? && !service_enabled_in_env?)
end