Sha256: 0ba9f68d175650708a34a8d14b9d9e732eebd6b32ccf1b8069fbdc94ef2f953f

Contents?: true

Size: 628 Bytes

Versions: 13

Compression:

Stored size: 628 Bytes

Contents

module DuckPuncher
  # @note When updating this file please update comment regarding this module in duck_puncher.rb
  module Utilities
    def lookup_constant(const)
      return const if ::Module === const
      if const.to_s.respond_to?(:constantize)
        const.to_s.constantize
      else
        const.to_s.split('::').inject(::Object) { |k, part| k.const_get(part) }
      end
    rescue ::NameError => e
      logger.error "#{e.class}: #{e.message}"
      nil
    end

    def redefine_constant(name, const)
      if const_defined? name
        remove_const name
      end
      const_set name, const
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
duck_puncher-5.0.1 lib/duck_puncher/utilities.rb
duck_puncher-5.0.0 lib/duck_puncher/utilities.rb
duck_puncher-4.5.1 lib/duck_puncher/utilities.rb
duck_puncher-4.5.0 lib/duck_puncher/utilities.rb
duck_puncher-4.4.2 lib/duck_puncher/utilities.rb
duck_puncher-4.4.1 lib/duck_puncher/utilities.rb
duck_puncher-4.4.0 lib/duck_puncher/utilities.rb
duck_puncher-4.3.1 lib/duck_puncher/utilities.rb
duck_puncher-4.3.0 lib/duck_puncher/utilities.rb
duck_puncher-4.2.3 lib/duck_puncher/utilities.rb
duck_puncher-4.2.2 lib/duck_puncher/utilities.rb
duck_puncher-4.2.1 lib/duck_puncher/utilities.rb
duck_puncher-4.2.0 lib/duck_puncher/utilities.rb