Class: Refinement::UsedPath

Inherits:
Object
  • Object
show all
Defined in:
lib/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.



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

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



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

def find_in_changeset(changeset)
  add_reason changeset.find_modification_for_path(absolute_path: path), changeset: 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)


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

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