Sha256: 18dbca20b06c78a72ceef0ea74d51bedfdb3bc039588ed3d71cd71156dcd2c89
Contents?: true
Size: 847 Bytes
Versions: 7
Compression:
Stored size: 847 Bytes
Contents
require_relative 'node' require_relative 'sexp_extensions' module Reek module AST # Maps AST node types to sublasses of ASTNode extended with the relevant # utility modules. # # @api private class ASTNodeClassMap def initialize @klass_map = {} end def klass_for(type) @klass_map[type] ||= Class.new(Node).tap do |klass| extension = extension_map[type] klass.send :include, extension if extension end end def extension_map @extension_map ||= begin assoc = SexpExtensions.constants.map do |const| [ const.to_s.sub(/Node$/, '').downcase.to_sym, SexpExtensions.const_get(const) ] end Hash[assoc] end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems