Class: Hakoy::RowNormalizer

Inherits:
Object
  • Object
show all
Defined in:
lib/hakoy/row_normalizer.rb

Constant Summary collapse

MissingRequiredKeysError =
Class.new(StandardError)

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ RowNormalizer

Returns a new instance of RowNormalizer.



5
6
7
8
# File 'lib/hakoy/row_normalizer.rb', line 5

def initialize(opts)
  @uid_key = opts.fetch(:uid_key)
  @required_keys = opts.fetch(:required_keys).dup.freeze
end

Instance Method Details

#normalize(hash) ⇒ Object Also known as: call



10
11
12
13
# File 'lib/hakoy/row_normalizer.rb', line 10

def normalize(hash)
  assert_has_required_keys!(hash, @required_keys)
  build_normalized_hash(hash)
end