Sha256: 238343f10fe18fc3f350cc196132bf50e736e9cfe612fcda2b663308e1cbc717
Contents?: true
Size: 1.49 KB
Versions: 2
Compression:
Stored size: 1.49 KB
Contents
module Inch module CodeObject # CodeObject::Proxy object represent code objects in the analaysed # codebase. # module Proxy class << self # Returns a Proxy object for the given +code_object+ # # @param code_object [YARD::Object::Base] # @return [CodeObject::Proxy::Base] def for(code_object) @cache ||= {} if proxy_object = @cache[cache_key(code_object)] proxy_object else attributes = Converter.to_hash(code_object) proxy_object = class_for(code_object).new(attributes) @cache[cache_key(code_object)] = proxy_object end end private # Returns a Proxy class for the given +code_object+ # # @param code_object [YARD::CodeObject] # @return [Class] def class_for(code_object) class_name = code_object.class.to_s.split('::').last eval("::Inch::CodeObject::Proxy::#{class_name}") rescue Base end # Returns a cache key for the given +code_object+ # # @return [String] def cache_key(code_object) code_object.fullname end end end end end require_relative 'proxy/base' require_relative 'proxy/namespace_object' require_relative 'proxy/class_object' require_relative 'proxy/constant_object' require_relative 'proxy/method_object' require_relative 'proxy/method_parameter_object' require_relative 'proxy/module_object'
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
inch-0.3.0.rc2 | lib/inch/code_object/proxy.rb |
inch-0.3.0.rc1 | lib/inch/code_object/proxy.rb |