Class: Sq::Refinement::UsedPath

Inherits:
Object
  • Object
show all
Defined in:
lib/sq/refinement/used_path.rb

Overview

Represents a path that some target depends upon.

Direct Known Subclasses

YAML

Defined Under Namespace

Classes: YAML

Instance Method Summary collapse

Constructor Details

#initialize(path:, inclusion_reason:) ⇒ UsedPath

Returns a new instance of UsedPath.



15
16
17
18
# File 'lib/sq/refinement/used_path.rb', line 15

def initialize(path:, inclusion_reason:)
  @path = path
  @inclusion_reason = inclusion_reason
end

Instance Method Details

#find_in_changeset(changeset) ⇒ Nil, String

Returns If the path has been modified, a string explaining the modification.

Parameters:

  • changeset (Changeset)

    the changeset to search for a modification to this path

Returns:

  • (Nil, String)

    If the path has been modified, a string explaining the modification



22
23
24
# File 'lib/sq/refinement/used_path.rb', line 22

def find_in_changeset(changeset)
  add_reason changeset.find_modification_for_path(absolute_path: path), changeset:
end

#find_in_changesets(changesets) ⇒ Nil, String

Returns If the path has been modified, a string explaining the modification.

Parameters:

  • changesets (Array<Changeset>)

    the changesets to search for a modification to this path

Returns:

  • (Nil, String)

    If the path has been modified, a string explaining the modification

Raises:

  • (ArgumentError)


28
29
30
31
32
33
34
# File 'lib/sq/refinement/used_path.rb', line 28

def find_in_changesets(changesets)
  raise ArgumentError, 'Must provide at least one changeset' if changesets.empty?

  changesets.reduce(true) do |explanation, changeset|
    explanation && find_in_changeset(changeset)
  end
end