Class: WebValve::FakeServiceConfig

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

Constant Summary collapse

ENABLED_VALUES =
%w(1 t true)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of FakeServiceConfig.



7
8
9
10
# File 'lib/webvalve/fake_service_config.rb', line 7

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

Instance Attribute Details

#serviceObject (readonly)

Returns the value of attribute service.



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

def service
  @service
end

Instance Method Details

#service_urlObject



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

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)


12
13
14
15
# File 'lib/webvalve/fake_service_config.rb', line 12

def should_intercept?
  Rails.env.test? ||
    (WebValve.enabled? && !service_enabled_in_env?)
end