Skip to content

Commit

Permalink
NH-66480: add back method_missing but with strict regex rule
Browse files Browse the repository at this point in the history
  • Loading branch information
xuan-cao-swi committed Jan 18, 2024
1 parent 678c795 commit 8bdf952
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/solarwinds_apm/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,27 @@ def self.[]=(key, value)
end
end
# rubocop:enable Metrics/AbcSize, Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity

def self.method_missing(sym, *args)
class_var_name = "@@#{sym}"

if sym.to_s =~ /\A(.{1,20})=\z/
self[$1] = args.first
else
# Try part of the @@config hash first
if @@config.key?(sym)
self[sym]

# Then try as a class variable
elsif self.class_variable_defined?(class_var_name.to_sym)
self.class_eval(class_var_name)

# Congrats - You've won a brand new nil...
else
nil
end
end
end
end
end

Expand Down

0 comments on commit 8bdf952

Please sign in to comment.