Class: Rigor::Plugin::EffectEntryPoints

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

Overview

One entry of a plugin's effect_entry_points: — a named set of globs that effects.snapshot.reach: may adopt by name (ADR-103 WD14).

reach: is "whose transitive footprint does the snapshot record", and the honest answer for a Rails app — controller actions, perform, mailer methods, channel methods — is a fact about the framework rather than about the project. So the framework's plugin names it and the project adopts it:

effects:
  snapshot:
    reach: [rails]

A preset is a glob set, matched against the project-relative file a method is defined in, with the rigor unused --entry-point semantics Effects::EntryPoints already implements. Globs rather than a class-ancestry filter, deliberately: reach: is resolved from the snapshot's own method table, which carries a defining path per key and no ancestry — and a Rails app's layout IS the ancestry, which is why the convention exists at all.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, globs:, why: "") ⇒ EffectEntryPoints

Returns a new instance of EffectEntryPoints.

Parameters:

  • name (String, Symbol)

    the token reach: adopts. Must satisfy Effects::EntryPoints::NAME_PATTERN, checked at registration.

  • globs (Array<String>)

    project-relative path globs

  • why (String) (defaults to: "")

    what the preset stands for, for the plugin's README and rigor effects' help

Raises:

  • (ArgumentError)


28
29
30
31
32
33
34
35
# File 'lib/rigor/plugin/effect_entry_points.rb', line 28

def initialize(name:, globs:, why: "")
  @name = name.to_s.dup.freeze
  @globs = Array(globs).map { |glob| glob.to_s.dup.freeze }.uniq.sort.freeze
  raise ArgumentError, "effect entry-point preset #{@name.inspect} declares no globs" if @globs.empty?

  @why = why.to_s.dup.freeze
  freeze
end

Instance Attribute Details

#globsObject (readonly)

Returns the value of attribute globs.



22
23
24
# File 'lib/rigor/plugin/effect_entry_points.rb', line 22

def globs
  @globs
end

#nameObject (readonly)

Returns the value of attribute name.



22
23
24
# File 'lib/rigor/plugin/effect_entry_points.rb', line 22

def name
  @name
end

#whyObject (readonly)

Returns the value of attribute why.



22
23
24
# File 'lib/rigor/plugin/effect_entry_points.rb', line 22

def why
  @why
end

Instance Method Details

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



41
42
43
# File 'lib/rigor/plugin/effect_entry_points.rb', line 41

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

#hashObject



46
47
48
# File 'lib/rigor/plugin/effect_entry_points.rb', line 46

def hash
  to_h.hash
end

#to_hObject



37
38
39
# File 'lib/rigor/plugin/effect_entry_points.rb', line 37

def to_h
  { "name" => @name, "globs" => @globs }
end