Module: Julewire::GCP::SourceLocationOptions

Defined in:
lib/julewire/gcp/source_location_options.rb

Class Method Summary collapse

Class Method Details

.call(record, neutral_attributes) ⇒ Object



10
11
12
13
14
15
# File 'lib/julewire/gcp/source_location_options.rb', line 10

def call(record, neutral_attributes)
  options = record.dig(:payload, :gcp, :source_location)
  return options if options.is_a?(Hash)

  from_neutral_attributes(neutral_attributes)
end

.from_neutral_attributes(neutral_attributes) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/julewire/gcp/source_location_options.rb', line 17

def from_neutral_attributes(neutral_attributes)
  file = neutral_attributes[Core::Fields::AttributeKeys::CODE_FILE_PATH]
  line = neutral_attributes[Core::Fields::AttributeKeys::CODE_LINE_NUMBER]
  function = neutral_attributes[Core::Fields::AttributeKeys::CODE_FUNCTION_NAME]
  return EMPTY_HASH if file.nil? && line.nil? && function.nil?

  values = Core::Integration::Values::Shape
  options = {}
  values.append_field(options, :file, file)
  values.append_field(options, :line, line)
  values.append_field(options, :function, function)
  options
end