Sha256: 2433d5e99a20c8aca4344e86b33e000459c4acc2398cafda9abeaa2ff09704c1
Contents?: true
Size: 828 Bytes
Versions: 1
Compression:
Stored size: 828 Bytes
Contents
require 'private_attr/everywhere' module Reek # @api private module AST # Responsible for holding one specific object reference ObjectRef = Struct.new(:name, :line) # # Manages and counts the references out of a method to other objects. # class ObjectRefs def initialize @refs = Hash.new { |refs, name| refs[name] = [] } end def most_popular max = refs.values.map(&:size).max refs.select { |_name, refs| refs.size == max } end def record_reference_to(name, line: nil) refs[name] << ObjectRef.new(name, line) end def references_to(name) refs[name] end def self_is_max? refs.empty? || most_popular.keys.include?(:self) end private private_attr_reader :refs end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
reek-3.3.1 | lib/reek/ast/object_refs.rb |