Sha256: 1c74bbc8afa62d93b8fd0998e40417b2109cbdf2f5f2b562c73603b6a2a7dd7b
Contents?: true
Size: 915 Bytes
Versions: 1
Compression:
Stored size: 915 Bytes
Contents
# frozen_string_literal: true module Yardcheck class Const include Concord::Public.new(:constant) def self.resolve(constant_name, scope = Object) return new(scope.const_get(constant_name)) if scope.const_defined?(constant_name) parent = parent_namespace(scope) from_parent = resolve(constant_name, parent.constant) if parent.valid? from_parent && from_parent.valid? ? from_parent : Invalid.new(scope, constant_name) end def self.parent_namespace(scope) parent_name = scope.name.split('::').slice(0...-1).join('::') if parent_name.empty? Invalid.new(Object, parent_name) else resolve(parent_name) end end def valid? true end class Invalid < self include Concord.new(:scope, :constant) public :constant def valid? false end end # Invalid end # Const end # Yardcheck
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
yardcheck-0.0.1 | lib/yardcheck/const.rb |