Class: Utopia::Project::Inheritance
- Inherits:
-
Object
- Object
- Utopia::Project::Inheritance
- Defined in:
- lib/utopia/project/inheritance.rb
Overview
Resolves relationships and inherited methods for a definition.
Defined Under Namespace
Classes: Group, Method, Relationship
Instance Attribute Summary collapse
-
#definition ⇒ Object
The definition being inspected.
Instance Method Summary collapse
-
#inherited_methods ⇒ Object
Enumerate documented public and protected methods inherited by the definition.
-
#initialize(index, definition) ⇒ Inheritance
constructor
Initialize inheritance resolution for the given definition.
-
#relationships ⇒ Object
Enumerate the directly declared relationships.
Constructor Details
#initialize(index, definition) ⇒ Inheritance
Initialize inheritance resolution for the given definition.
22 23 24 25 |
# File 'lib/utopia/project/inheritance.rb', line 22 def initialize(index, definition) @index = index @definition = definition end |
Instance Attribute Details
#definition ⇒ Object
The definition being inspected.
29 30 31 |
# File 'lib/utopia/project/inheritance.rb', line 29 def definition @definition end |
Instance Method Details
#inherited_methods ⇒ Object
Enumerate documented public and protected methods inherited by the definition.
59 60 61 62 63 64 65 66 67 |
# File 'lib/utopia/project/inheritance.rb', line 59 def inherited_methods @groups = [] @groups_by_definition = {} collect_instance_methods(@definition, false, {}, {}) collect_class_methods(@definition, false, {}, {}) return @groups end |
#relationships ⇒ Object
Enumerate the directly declared relationships.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/utopia/project/inheritance.rb', line 33 def relationships @relationships ||= begin relationships = [] if @definition.respond_to?(:super_class) && (name = @definition.super_class) relationships << relationship(:super_class, name) end { prepends: :prepend, includes: :include, extends: :extend, }.each do |attribute, kind| if @definition.respond_to?(attribute) @definition.public_send(attribute).each do |name| relationships << relationship(kind, name) end end end relationships end end |