Class: JsDuck::MembersIndex
- Inherits:
-
Object
- Object
- JsDuck::MembersIndex
- Defined in:
- lib/jsduck/members_index.rb
Overview
Helper for JsDuck::Class for indexing its members.
While indexing the members of a class it accesses the MembersIndex instances of parent and mixins of that class through the #members_index accessor. This isn’t the nicest approach, but better than having all of this functionality inside the JsDuck::Class itself.
Instance Method Summary collapse
-
#all_global ⇒ Object
Returns array of all members (including inherited ones).
-
#all_local ⇒ Object
Returns array of all local members (excludes inherited ones).
-
#global_by_name ⇒ Object
Returns hash of all members by name (including inherited ones).
-
#initialize(cls) ⇒ MembersIndex
constructor
A new instance of MembersIndex.
-
#invalidate! ⇒ Object
Clears the search cache.
Constructor Details
#initialize(cls) ⇒ MembersIndex
Returns a new instance of MembersIndex.
13 14 15 16 17 18 |
# File 'lib/jsduck/members_index.rb', line 13 def initialize(cls) @cls = cls @map_by_id = nil @global_map_by_id = nil @global_map_by_name = nil end |
Instance Method Details
#all_global ⇒ Object
Returns array of all members (including inherited ones)
35 36 37 |
# File 'lib/jsduck/members_index.rb', line 35 def all_global global_by_id.values end |
#all_local ⇒ Object
Returns array of all local members (excludes inherited ones)
40 41 42 |
# File 'lib/jsduck/members_index.rb', line 40 def all_local local_by_id.values.reject {|m| m[:hide] } end |
#global_by_name ⇒ Object
Returns hash of all members by name (including inherited ones)
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/jsduck/members_index.rb', line 21 def global_by_name unless @global_map_by_name @global_map_by_name = {} global_by_id.each_pair do |id, m| @global_map_by_name[m[:name]] = [] unless @global_map_by_name[m[:name]] @global_map_by_name[m[:name]] << m end end @global_map_by_name end |
#invalidate! ⇒ Object
Clears the search cache.
Using this degrades performance. It’s currently triggered just once after InheritDoc process is run. Avoid using it in other places.
49 50 51 52 53 |
# File 'lib/jsduck/members_index.rb', line 49 def invalidate! @map_by_id = nil @global_map_by_id = nil @global_map_by_name = nil end |