lib/analyst/entities/class.rb in analyst-0.15.0 vs lib/analyst/entities/class.rb in analyst-0.16.1

- old
+ new

@@ -1,48 +1,38 @@ -#TODO add == to association -# TODO look thru the singleton_methods for ones on (self), -# and also look for the ones from 'class << self' constructs, which will be -# found in (sclass) nodes (which will be some sort of Entity) - module Analyst - module Entities - class Class < Analyst::Entities::Module + class Class < Entity + include HasMethods + handles_node :class alias :macros :method_calls def kind "Class" end - def imethods - @imethods ||= contents.select { |entity| entity.is_a? Analyst::Entities::InstanceMethod } + def singleton_class_blocks + contents.select { |entity| entity.is_a? Analyst::Entities::SingletonClass } end - def cmethods - some_methods = smethods.select { |method| method.target.type == :self } - other_methods = singleton_class_blocks { |block| block.target.type == :self }.map(&:smethods).flatten - some_methods + other_methods + def name + name_entity.name end - def all_methods - cmethods + imethods + def full_name + parent.full_name.empty? ? name : parent.full_name + '::' + name end - def singleton_class_blocks - contents.select { |entity| entity.is_a? Analyst::Entities::SingletonClass } - end - private - def smethods - @smethods ||= contents.select do |entity| - entity.is_a? Analyst::Entities::SingletonMethod - end + def name_entity + @name_entity ||= process_node(name_node) end + def name_node + ast.children.first + end end - end end