Sha256: 95c5ffac4364cbd97c6142a0b8051aeaededae3423e69cfd473017f0ed9356c0

Contents?: true

Size: 630 Bytes

Versions: 1

Compression:

Stored size: 630 Bytes

Contents

# frozen_string_literal: true

if ActiveObject.configuration.autoload_kernel
  module Kernel

    SANITIZE_EVAL_REGEX ||= /\[\d*,?\d*,?\d*\]/

    # rubocop:disable Lint/RescueException, Security/Eval
    def safe_eval
      val = SANITIZE_EVAL_REGEX.match(to_s).to_s
      return if val.nil?

      eval(val)
    end

    def try_eval
      eval(self)
    rescue Exception
      self
    end
    # rubocop:enable Lint/RescueException, Security/Eval

    private

    # rubocop:disable Style/PerlBackrefs
    def caller_name
      caller(1..1).first =~ /`([^']*)'/ && $1
    end
    # rubocop:enable Style/PerlBackrefs

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_object-5.5.1 lib/active_object/kernel.rb