Sha256: 88e346f7cbf75210be4381eef5612a6e6e26d326a688b85dbb1bcf0ad080033c
Contents?: true
Size: 1.92 KB
Versions: 2
Compression:
Stored size: 1.92 KB
Contents
require "inch/language/elixir/provider/reader/object/base" require "inch/language/elixir/provider/reader/object/function_object" require "inch/language/elixir/provider/reader/object/module_object" require "inch/language/elixir/provider/reader/object/type_object" module Inch module Language module Elixir module Provider module Reader # CodeObject::Provider::JSDoc::Object object represent code objects. # module Object class << self def clear_cache @cache = {} end # Returns a Proxy object for the given +json_object+ # # @param json_object [Hash] # @return [Provider::JSDoc::Object] def for(json_object) @cache ||= {} if proxy_object = @cache[cache_key(json_object)] proxy_object else @cache[cache_key(json_object)] = class_for(json_object).new(json_object) end end private # Returns a Proxy class for the given +json_object+ # # @param json_object [Hash] # @return [Class] def class_for(json_object) class_name = json_object['object_type'] Reader::Object.const_get(class_name) rescue NameError Reader::Object::Base end # Returns a cache key for the given +json_object+ # # @param json_object [Hash] # @return [String] def cache_key(json_object) [ json_object['id'], json_object['module_id'], json_object['signature'] ].map(&:to_s).join('.') end end end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
inch-0.5.0.rc5 | lib/inch/language/elixir/provider/reader/object.rb |
inch-0.5.0.rc4 | lib/inch/language/elixir/provider/reader/object.rb |