class Abstractable::NotImplementedInfoFinder
this class can find to information of unimplemented abstract method
Public Instance Methods
find(klass)
click to toggle source
find(klass) -> hash
Returns an hash as information of unimplemented abstract method. hash format is {class => array of unimplemented method in class, … }
# File lib/abstractable/not_implemented_info_finder.rb, line 11 def find(klass) find_from_pedigree_stream(PedigreeStream.new(klass)) end
find_from_singleton(klass)
click to toggle source
find_from_singleton
(klass) -> hash singleton_class version find.
# File lib/abstractable/not_implemented_info_finder.rb, line 17 def find_from_singleton(klass) find_from_pedigree_stream(SingletonPedigreeStream.new(klass)) end
Private Instance Methods
create_deny_empty_array_hash()
click to toggle source
# File lib/abstractable/not_implemented_info_finder.rb, line 29 def create_deny_empty_array_hash hash = {} def hash.[]=(key, value) super(key, value) unless value.empty? end hash end
find_from_ancestor_and_descendants(ancestor, descendants)
click to toggle source
# File lib/abstractable/not_implemented_info_finder.rb, line 41 def find_from_ancestor_and_descendants(ancestor, descendants) ancestor.abstract_methods(false).reject { |method| descendants.any?(&individual_method_defined?(method)) } end
find_from_pedigree_stream(pedigree_stream)
click to toggle source
# File lib/abstractable/not_implemented_info_finder.rb, line 23 def find_from_pedigree_stream(pedigree_stream) pedigree_stream.each_with_descendants_and_object(create_deny_empty_array_hash) do |klass, descendants, hash| hash[klass] = find_from_ancestor_and_descendants(klass, descendants) if need_find?(klass, descendants) end end
individual_method_defined?(method)
click to toggle source
# File lib/abstractable/not_implemented_info_finder.rb, line 45 def individual_method_defined?(method) lambda { |klass| klass.instance_methods(false).include? method } end
need_find?(ancestor, descendants)
click to toggle source
# File lib/abstractable/not_implemented_info_finder.rb, line 37 def need_find?(ancestor, descendants) ancestor.is_a?(Abstractable) && 0 < descendants.size end