Module: ScoutApm::AttributeArranger

Defined in:
lib/scout_apm/attribute_arranger.rb

Class Method Summary collapse

Class Method Details

.call(subject, attributes_list) ⇒ Object

pass in an array of symbols to return as hash keys if the symbol doesn’t match the name of the method, pass an array: [:key, :method_name]



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/scout_apm/attribute_arranger.rb', line 5

def self.call(subject, attributes_list)
  attributes_list.inject({}) do |attribute_hash, attribute|
    case attribute
    when Array
      attribute_hash[attribute[0]] = subject.send(attribute[1])
    when :bucket
      attribute_hash[attribute] = subject.bucket_type
    when :name
      attribute_hash[attribute] = subject.bucket_name
    when Symbol
      attribute_hash[attribute] = subject.send(attribute)
    end
    attribute_hash
  end
end