Class: Rigor::Plugin::EffectAncestry

Inherits:
Object
  • Object
show all
Defined in:
lib/rigor/plugin/effect_ancestry.rb

Overview

One entry of a plugin's effect_ancestry: — an ancestry edge the plugin's own gem introduces and the project's source never writes down (ADR-103 WD17; #465).

Effects::PluginFacts walks the project's own class … < and include lines and nothing else, deliberately: reading the RBS ancestor chain instead would make a row's reach a function of whether anyone happened to run rbs prototype. The cost is that a chain which leaves project source never comes back. class UserMailer < Devise::Mailer is the measured case — Devise::Mailer < ActionMailer::Base is a line in the devise gem, so rigor-actionmailer's rows stop one step short of every mailer a Devise application writes, and the five Auth::*Controller < Devise::*Controller subclasses beside it are entry points.

A plugin that models a gem knows that gem's own inheritance. Declaring it here keeps the rule that Rigor reads declarations rather than RBS: the declaration simply comes from the plugin instead of from project source.

What a claim may say

parent: need only be a true ancestor, not the immediate superclass. The sole use of the ancestry is to make a row reachable, and no plugin row is ever keyed on a project class, so skipping intermediate links loses nothing — while insisting on the immediate parent would force a claim that is sometimes false: Devise::SessionsController's real parent is DeviseController, whose own parent is Devise.parent_controller and therefore configurable per project. A claim that skips links MUST say so in its why:.

Who may make one

Bundled plugins only (FirstParty), enforced in PluginFacts. An ancestry claim carries no labels of its own, so it looks harmless — but it makes other plugins' rows reachable, and a third-party plugin asserting Foo < ActiveRecord::Base would pull rigor-activerecord's first-party discharging rows onto Foo. The effect_root: demotion and the discharge: grant both answer their own version of that question the same way.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(child:, parent:, why:) ⇒ EffectAncestry

Returns a new instance of EffectAncestry.



41
42
43
44
45
46
# File 'lib/rigor/plugin/effect_ancestry.rb', line 41

def initialize(child:, parent:, why:)
  @child = validate_class_name!(child, "child")
  @parent = validate_class_name!(parent, "parent")
  @why = validate_why!(why)
  freeze
end

Instance Attribute Details

#childObject (readonly)

Returns the value of attribute child.



39
40
41
# File 'lib/rigor/plugin/effect_ancestry.rb', line 39

def child
  @child
end

#parentObject (readonly)

Returns the value of attribute parent.



39
40
41
# File 'lib/rigor/plugin/effect_ancestry.rb', line 39

def parent
  @parent
end

#whyObject (readonly)

Returns the value of attribute why.



39
40
41
# File 'lib/rigor/plugin/effect_ancestry.rb', line 39

def why
  @why
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



52
53
54
# File 'lib/rigor/plugin/effect_ancestry.rb', line 52

def ==(other)
  other.is_a?(EffectAncestry) && to_h == other.to_h
end

#hashObject



57
58
59
# File 'lib/rigor/plugin/effect_ancestry.rb', line 57

def hash
  to_h.hash
end

#to_hObject



48
49
50
# File 'lib/rigor/plugin/effect_ancestry.rb', line 48

def to_h
  { "child" => @child, "parent" => @parent }
end