Method: YARD::CodeObjects::Proxy#initialize
- Defined in:
- lib/yard/code_objects/proxy.rb
permalink #initialize(namespace, name, type = nil) ⇒ Proxy
Creates a new Proxy
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/yard/code_objects/proxy.rb', line 34 def initialize(namespace, name, type = nil) namespace = Registry.root if !namespace || namespace == :root if name =~ /^#{NSEPQ}/ namespace = Registry.root name = name[2..-1] end if name =~ PROXY_MATCH @orignamespace = namespace @origname = name @imethod = true if name.include? ISEP namespace = Proxy.new(namespace, $`) unless $`.empty? name = $1 else @orignamespace = nil @origname = nil @imethod = nil end @name = name.to_sym @namespace = namespace @obj = nil @imethod ||= nil self.type = type if @namespace.is_a?(ConstantObject) unless @namespace.value =~ /\A#{NAMESPACEMATCH}\Z/ raise Parser::UndocumentableError, "constant mapping for " + "#{@origname} (type=#{type.inspect})" end @origname = nil # forget these for a constant @orignamespace = nil @namespace = Proxy.new(@namespace.namespace, @namespace.value) end unless @namespace.is_a?(NamespaceObject) || @namespace.is_a?(Proxy) raise ArgumentError, "Invalid namespace object: #{namespace}" end # If the name begins with "::" (like "::String") # this is definitely a root level object, so # remove the namespace and attach it to the root if @name =~ /^#{NSEPQ}/ @name.gsub!(/^#{NSEPQ}/, '') @namespace = Registry.root end end |