Sha256: 3cb0539635cdabc774b2a8f277e1d74cf9cb7f3065e34b2c11f5ca04505e68cd

Contents?: true

Size: 630 Bytes

Versions: 4

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
      eval(self)
    rescue Exception
      self
    end

    def try_eval
      val = SANITIZE_EVAL_REGEX.match(to_s).to_s
      return if val.nil?

      eval(val)
    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

4 entries across 4 versions & 1 rubygems

Version Path
active_object-5.7.0 lib/active_object/kernel.rb
active_object-5.6.0 lib/active_object/kernel.rb
active_object-5.5.3 lib/active_object/kernel.rb
active_object-5.5.2 lib/active_object/kernel.rb