Class: Rookout::Processor::Operations::SetOperation

Inherits:
Operation
  • Object
show all
Defined in:
lib/rookout/processor/operations/set_operation.rb

Instance Method Summary collapse

Constructor Details

#initialize(configuration, factory) ⇒ SetOperation

Returns a new instance of SetOperation.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rookout/processor/operations/set_operation.rb', line 13

def initialize configuration, factory
  super()

  @paths = []

  configuration["paths"].each do |key, value|
    begin
      dest_path = factory.create_path key
      source_path = factory.create_path value
      @paths.push [dest_path, source_path]
    rescue StandardError => e
      message = "Failed to load dest:source path pair"
      Logger.instance.exception message, e
      warning = RookError.new e, message
      UserWarnings.notify_warning warning
    end
  end
end

Instance Method Details

#execute(namespace) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/rookout/processor/operations/set_operation.rb', line 32

def execute namespace
  @paths.each do |dest_path, source_path|
    begin
      value = source_path.read_from namespace
      if value.is_a?(Namespaces::RubyObjectNamespace) &&
         value.dump_config == Namespaces::OBJECT_DUMP_CONFIG_DEFAULT
        value.tailor_limits!
      end

      dest_path.write_to namespace, value
    rescue StandardError => e
      message = "Failed to execute dest:source path pair"
      Logger.instance.exception message, e
      warning = RookError.new e, message
      UserWarnings.notify_warning warning
    end
  end
end