Class: Ahnnotate::Facet::Models::ModuleNode
- Inherits:
-
Object
- Object
- Ahnnotate::Facet::Models::ModuleNode
- Includes:
- ActiveRecord::ModelSchema::ClassMethods
- Defined in:
- lib/ahnnotate/facet/models/module_node.rb
Overview
ModuleNode is named as such since ‘Class.is_a?(Module) == true`.
Instance Attribute Summary collapse
-
#abstract_class ⇒ Object
writeonly
Sets the attribute abstract_class.
- #claimed_superclass ⇒ Object
-
#explicit_table_name ⇒ Object
Returns the value of attribute explicit_table_name.
-
#is_a_kind_of_activerecord_base ⇒ Object
writeonly
Sets the attribute is_a_kind_of_activerecord_base.
-
#is_active_record_base ⇒ Object
Returns the value of attribute is_active_record_base.
-
#name ⇒ Object
Named to fit the ModelSchema interface.
-
#parent ⇒ Object
Named to fit the ModelSchema interface.
-
#path ⇒ Object
Returns the value of attribute path.
-
#superclass ⇒ Object
Named to fit the ModelSchema interface.
-
#table_name_prefix ⇒ Object
Named to fit the ModelSchema interface.
Instance Method Summary collapse
- #<(other) ⇒ Object
- #==(other) ⇒ Object
-
#abstract_class? ⇒ Boolean
Named to fit the ModelSchema interface.
-
#base_class ⇒ Object
Named to fit the ModelSchema interface.
- #class_name ⇒ Object
-
#initialize(name, parent: nil, is_a_kind_of_activerecord_base: false, claimed_superclass: nil, explicit_table_name: nil, abstract_class: nil) ⇒ ModuleNode
constructor
A new instance of ModuleNode.
- #is_a_kind_of_activerecord_base? ⇒ Boolean
-
#parents ⇒ Object
Named to fit the ModelSchema interface.
-
#pluralize_table_names ⇒ Object
Named to fit the ModelSchema interface.
- #table_name ⇒ Object
- #table_name_suffix ⇒ Object
Constructor Details
#initialize(name, parent: nil, is_a_kind_of_activerecord_base: false, claimed_superclass: nil, explicit_table_name: nil, abstract_class: nil) ⇒ ModuleNode
Returns a new instance of ModuleNode.
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/ahnnotate/facet/models/module_node.rb', line 33 def initialize(name, parent: nil, is_a_kind_of_activerecord_base: false, claimed_superclass: nil, explicit_table_name: nil, abstract_class: nil) self.name = name self.parent = parent self.is_a_kind_of_activerecord_base = is_a_kind_of_activerecord_base self.claimed_superclass = claimed_superclass self.explicit_table_name = explicit_table_name self.abstract_class = abstract_class end |
Instance Attribute Details
#abstract_class=(value) ⇒ Object (writeonly)
Sets the attribute abstract_class
27 28 29 |
# File 'lib/ahnnotate/facet/models/module_node.rb', line 27 def abstract_class=(value) @abstract_class = value end |
#claimed_superclass ⇒ Object
64 65 66 |
# File 'lib/ahnnotate/facet/models/module_node.rb', line 64 def claimed_superclass @claimed_superclass.to_s end |
#explicit_table_name ⇒ Object
Returns the value of attribute explicit_table_name.
29 30 31 |
# File 'lib/ahnnotate/facet/models/module_node.rb', line 29 def explicit_table_name @explicit_table_name end |
#is_a_kind_of_activerecord_base=(value) ⇒ Object (writeonly)
Sets the attribute is_a_kind_of_activerecord_base
28 29 30 |
# File 'lib/ahnnotate/facet/models/module_node.rb', line 28 def is_a_kind_of_activerecord_base=(value) @is_a_kind_of_activerecord_base = value end |
#is_active_record_base ⇒ Object
Returns the value of attribute is_active_record_base.
30 31 32 |
# File 'lib/ahnnotate/facet/models/module_node.rb', line 30 def is_active_record_base @is_active_record_base end |
#name ⇒ Object
Named to fit the ModelSchema interface. This is basically ‘Class#name`
16 17 18 |
# File 'lib/ahnnotate/facet/models/module_node.rb', line 16 def name @name end |
#parent ⇒ Object
Named to fit the ModelSchema interface. This is the “outer class”
18 19 20 |
# File 'lib/ahnnotate/facet/models/module_node.rb', line 18 def parent @parent end |
#path ⇒ Object
Returns the value of attribute path.
31 32 33 |
# File 'lib/ahnnotate/facet/models/module_node.rb', line 31 def path @path end |
#superclass ⇒ Object
Named to fit the ModelSchema interface. This is the class that the current class inherits from. This is computed, whereas claimed_superclass is what is parsed from the source
22 23 24 |
# File 'lib/ahnnotate/facet/models/module_node.rb', line 22 def superclass @superclass end |
#table_name_prefix ⇒ Object
Named to fit the ModelSchema interface. This is currently unsupported
24 25 26 |
# File 'lib/ahnnotate/facet/models/module_node.rb', line 24 def table_name_prefix @table_name_prefix end |
Instance Method Details
#<(other) ⇒ Object
109 110 111 |
# File 'lib/ahnnotate/facet/models/module_node.rb', line 109 def <(other) other == ActiveRecord::Base && is_a_kind_of_activerecord_base? end |
#==(other) ⇒ Object
113 114 115 116 117 118 119 |
# File 'lib/ahnnotate/facet/models/module_node.rb', line 113 def ==(other) if is_active_record_base && other == ActiveRecord::Base return true end super end |
#abstract_class? ⇒ Boolean
Named to fit the ModelSchema interface
60 61 62 |
# File 'lib/ahnnotate/facet/models/module_node.rb', line 60 def abstract_class? !!@abstract_class end |
#base_class ⇒ Object
Named to fit the ModelSchema interface. It was originally implemented in ActiveRecord::Inheritance. I’ve re-implemented it here via the documentation.
71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/ahnnotate/facet/models/module_node.rb', line 71 def base_class if superclass.is_active_record_base return self end if superclass.abstract_class? return self end superclass.base_class end |
#class_name ⇒ Object
93 94 95 96 97 98 99 |
# File 'lib/ahnnotate/facet/models/module_node.rb', line 93 def class_name if @name "#{parent.class_name}::#{@name}" else "" end end |
#is_a_kind_of_activerecord_base? ⇒ Boolean
55 56 57 |
# File 'lib/ahnnotate/facet/models/module_node.rb', line 55 def is_a_kind_of_activerecord_base? !!@is_a_kind_of_activerecord_base end |
#parents ⇒ Object
Named to fit the ModelSchema interface. It was originally implemented in ActiveSupport::Introspection
85 86 87 88 89 90 91 |
# File 'lib/ahnnotate/facet/models/module_node.rb', line 85 def parents if parent [parent, *parent.parent] else [] end end |
#pluralize_table_names ⇒ Object
Named to fit the ModelSchema interface
48 49 50 |
# File 'lib/ahnnotate/facet/models/module_node.rb', line 48 def pluralize_table_names true end |
#table_name ⇒ Object
101 102 103 104 105 106 107 |
# File 'lib/ahnnotate/facet/models/module_node.rb', line 101 def table_name if explicit_table_name return @explicit_table_name end super end |
#table_name_suffix ⇒ Object
52 53 |
# File 'lib/ahnnotate/facet/models/module_node.rb', line 52 def table_name_suffix end |