Module: Harmonize::Base::ClassMethods

Defined in:
lib/harmonize/base.rb

Instance Method Summary collapse

Instance Method Details

#harmonize(options = {}) {|configuration| ... } ⇒ Object

Enable harmonization on a set of records

Yields:

  • (configuration)


13
14
15
16
17
# File 'lib/harmonize/base.rb', line 13

def harmonize(options = {})
  configuration = Harmonize::Configuration.new(options)
  yield(configuration) if block_given?
  configure_harmonizer(configuration)
end

#harmonize!(harmonizer_name) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/harmonize/base.rb', line 23

def harmonize!(harmonizer_name)
  raise UnknownHarmonizerName.new(harmonizer_name.to_s) unless harmonizers.has_key?(harmonizer_name)
  harmonizer = harmonizers[harmonizer_name]
  harmonize_log = create_harmonize_log(harmonizer_name)
  strategy = harmonizer.strategy.new(*harmonizer.strategy_arguments)
  strategy.harmonize(:harmonizer => harmonizer, :harmonize_log => harmonize_log)
  close_harmonize_log(harmonize_log)
end

#harmonizersObject



19
20
21
# File 'lib/harmonize/base.rb', line 19

def harmonizers
  @harmonizers ||= {}
end

#remove_harmonizer!(harmonizer_name = :default) ⇒ Object



32
33
34
# File 'lib/harmonize/base.rb', line 32

def remove_harmonizer!(harmonizer_name = :default)
  harmonizers.delete(harmonizer_name)
end