lib/active_object/kernel.rb in active_object-5.4.0 vs lib/active_object/kernel.rb in active_object-5.5.0

- old
+ new

@@ -1,10 +1,19 @@ # frozen_string_literal: true if ActiveObject.configuration.autoload_kernel module Kernel + SANITIZE_EVAL_REGEX ||= /\[\d*,?\d*,?\d*\]/.freeze + # rubocop:disable Lint/RescueException, Security/Eval + def safe_eval + val = SANITIZE_EVAL_REGEX.match(self.to_s).to_s + return if val.nil? + + eval(val) + end + def try_eval eval(self) rescue Exception self end