class Ahnnotate::Facet::Models::ModuleNode

ModuleNode is named as such since `Class.is_a?(Module) == true`.

Attributes

abstract_class[W]
claimed_superclass[W]
explicit_table_name[RW]
is_a_kind_of_activerecord_base[W]
is_active_record_base[RW]
module_parent[RW]

Named to fit the ModelSchema interface. This is the “outer class”

name[RW]

Named to fit the ModelSchema interface. This is basically `Class#name`

path[RW]
superclass[RW]

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

table_name_prefix[RW]

Named to fit the ModelSchema interface. This is currently unsupported

Public Class Methods

new(name, module_parent: nil, is_a_kind_of_activerecord_base: false, claimed_superclass: nil, explicit_table_name: nil, abstract_class: nil) click to toggle source
# File lib/ahnnotate/facet/models/module_node.rb, line 33
def initialize(name,
  module_parent: nil,
  is_a_kind_of_activerecord_base: false,
  claimed_superclass: nil,
  explicit_table_name: nil,
  abstract_class: nil)
  self.name = name
  self.module_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

Public Instance Methods

<(other) click to toggle source
# File lib/ahnnotate/facet/models/module_node.rb, line 115
def <(other)
  other == ActiveRecord::Base && is_a_kind_of_activerecord_base?
end
==(other) click to toggle source
Calls superclass method
# File lib/ahnnotate/facet/models/module_node.rb, line 119
def ==(other)
  if is_active_record_base && other == ActiveRecord::Base
    return true
  end

  super
end
abstract_class?() click to toggle source

Named to fit the ModelSchema interface

# File lib/ahnnotate/facet/models/module_node.rb, line 60
def abstract_class?
  !!@abstract_class
end
base_class() click to toggle source

Named to fit the ModelSchema interface. It was originally implemented in ActiveRecord::Inheritance. I've re-implemented it here via the documentation.

# 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
base_class?() click to toggle source

Named to fit the ModelSchema interface. It was originally implemented in ActiveRecord::Inheritance in Rails 6.0.

# File lib/ahnnotate/facet/models/module_node.rb, line 85
def base_class?
  base_class == self
end
claimed_superclass() click to toggle source
# File lib/ahnnotate/facet/models/module_node.rb, line 64
def claimed_superclass
  @claimed_superclass.to_s
end
class_name() click to toggle source
# File lib/ahnnotate/facet/models/module_node.rb, line 99
def class_name
  if @name
    "#{parent.class_name}::#{@name}"
  else
    ""
  end
end
is_a_kind_of_activerecord_base?() click to toggle source
# File lib/ahnnotate/facet/models/module_node.rb, line 55
def is_a_kind_of_activerecord_base?
  !!@is_a_kind_of_activerecord_base
end
module_parents() click to toggle source

Named to fit the ModelSchema interface. It was originally implemented in ActiveSupport::Introspection

# File lib/ahnnotate/facet/models/module_node.rb, line 91
def module_parents
  if module_parent
    [module_parent, *module_parent.module_parent]
  else
    []
  end
end
pluralize_table_names() click to toggle source

Named to fit the ModelSchema interface

# File lib/ahnnotate/facet/models/module_node.rb, line 48
def pluralize_table_names
  true
end
table_name() click to toggle source
Calls superclass method
# File lib/ahnnotate/facet/models/module_node.rb, line 107
def table_name
  if explicit_table_name
    return @explicit_table_name
  end

  super
end
table_name_suffix() click to toggle source
# File lib/ahnnotate/facet/models/module_node.rb, line 52
def table_name_suffix
end