Sha256: d8856d5b22c3e774a418d323f8cc4ed47b77894684f215e7bd0e602f648ded1e

Contents?: true

Size: 1.19 KB

Versions: 5

Compression:

Stored size: 1.19 KB

Contents

module Ahnnotate
  module Facet
    module Models
      class Standin
        # Lol. It's a little easier in this case to deal with instances here.
        # I'll need to create many instances to recreate the class structure of
        # the models in order to most correctly compute the table name from the
        # model name 🥳
        include ActiveRecord::ModelSchema::ClassMethods

        # boolean, is this an abstract class
        attr_writer :abstract_class
        # the class that the current class inherits from
        attr_accessor :superclass
        attr_accessor :base_class
        # the outer class
        attr_accessor :parent

        def initialize(abstract_class:, superclass:, base_class:, parent:, is_active_record_base: false)
          @abstract_class = abstract_class
          @superclass = superclass
          @base_class = base_class
          @parent = parent
          @is_active_record_base = is_active_record_base
        end

        def abstract_class?
          !!@abstract_class
        end

        def ==(other)
          if @is_active_record_base && other == ActiveRecord::Base
            return true
          end

          super
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ahnnotate-0.5.1 lib/ahnnotate/facet/models/standin.rb
ahnnotate-0.5.0 lib/ahnnotate/facet/models/standin.rb
ahnnotate-0.4.0 lib/ahnnotate/facet/models/standin.rb
ahnnotate-0.3.0 lib/ahnnotate/facet/models/standin.rb
ahnnotate-0.2.0 lib/ahnnotate/facet/models/standin.rb