Class: NcsNavigator::Warehouse::Transformers::ForeignKeyIndex::StaticKeyProvider

Inherits:
Object
  • Object
show all
Defined in:
lib/ncs_navigator/warehouse/transformers/foreign_key_index/static_key_provider.rb

Overview

An existing key provider for NcsNavigator::Warehouse::Transformers::ForeignKeyIndex that uses a statically configured hash of keys.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(known_keys = {}) ⇒ StaticKeyProvider

Returns a new instance of StaticKeyProvider.



11
12
13
# File 'lib/ncs_navigator/warehouse/transformers/foreign_key_index/static_key_provider.rb', line 11

def initialize(known_keys={})
  @known_keys = known_keys
end

Instance Attribute Details

#known_keysObject

Returns the value of attribute known_keys.



9
10
11
# File 'lib/ncs_navigator/warehouse/transformers/foreign_key_index/static_key_provider.rb', line 9

def known_keys
  @known_keys
end

Instance Method Details

#existing_keys(model_class) ⇒ Object



15
16
17
18
19
# File 'lib/ncs_navigator/warehouse/transformers/foreign_key_index/static_key_provider.rb', line 15

def existing_keys(model_class)
  # validation is to help with the uses of this class in specs
  fail 'model_class must be a string' unless Class === model_class
  known_keys[model_class.to_s]
end