Class: TranslationDiff::Configuration::ProviderOptionOwners

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

Overview

Tracks which provider declared each option; two silently sharing one accessor would leak a credential.

Instance Method Summary collapse

Constructor Details

#initialize ⇒ ProviderOptionOwners

Returns a new instance of ProviderOptionOwners.



3
4
5
# File 'lib/translation_diff/configuration/provider_option_owners.rb', line 3

def initialize
  @owners = {}
end

Instance Method Details

#claim(keys, provider) ⇒ Object

All-or-nothing: recording key by key would attribute earlier keys to a provider that then failed.



8
9
10
11
# File 'lib/translation_diff/configuration/provider_option_owners.rb', line 8

def claim(keys, provider)
  validate!(keys, provider)
  keys.each { |key| @owners[key] = provider }
end