lib/active_object/kernel.rb in active_object-5.7.0 vs lib/active_object/kernel.rb in active_object-5.8.0
- old
+ new
@@ -1,13 +1,14 @@
# frozen_string_literal: true
if ActiveObject.configuration.autoload_kernel
module Kernel
- SANITIZE_EVAL_REGEX ||= /\[\d*,?\d*,?\d*\]/
+ SANITIZE_EVAL_REGEX ||= /\[\d*,?\d*,?\d*\]/.freeze
+ CALLER_METHOD_REGEX ||= /`([^']*)'/.freeze
- # rubocop:disable Lint/RescueException, Security/Eval
+ # rubocop:disable Security/Eval
def safe_eval
eval(self)
rescue Exception
self
end
@@ -16,16 +17,16 @@
val = SANITIZE_EVAL_REGEX.match(to_s).to_s
return if val.nil?
eval(val)
end
- # rubocop:enable Lint/RescueException, Security/Eval
+ # rubocop:enable Security/Eval
private
# rubocop:disable Style/PerlBackrefs
def caller_name
- caller(1..1).first =~ /`([^']*)'/ && $1
+ caller(1..1).first =~ CALLER_METHOD_REGEX && $1
end
# rubocop:enable Style/PerlBackrefs
end
end