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



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

def call(record, neutral_attributes)
  control = record.fetch(:payload)[:gcp]
  return from_neutral_attributes(neutral_attributes) unless control.is_a?(Hash)

  options = control[: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
# 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]
  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