Class: Shanty::Mutator

Inherits:
Object
  • Object
show all
Defined in:
lib/shanty/mutator.rb

Overview

Public: enables mutation of the project graph Common usage would be to set changed flags on projects

Direct Known Subclasses

BundlerMutator, ChangedMutator

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env, graph) ⇒ Mutator

Returns a new instance of Mutator.



13
14
15
16
# File 'lib/shanty/mutator.rb', line 13

def initialize(env, graph)
  @env = env
  @graph = graph
end

Class Attribute Details

.mutatorsObject (readonly)

Returns the value of attribute mutators.



8
9
10
# File 'lib/shanty/mutator.rb', line 8

def mutators
  @mutators
end

Instance Attribute Details

#envObject (readonly)

Returns the value of attribute env.



11
12
13
# File 'lib/shanty/mutator.rb', line 11

def env
  @env
end

#graphObject (readonly)

Returns the value of attribute graph.



11
12
13
# File 'lib/shanty/mutator.rb', line 11

def graph
  @graph
end

Class Method Details

.inherited(mutator) ⇒ Object



18
19
20
21
22
# File 'lib/shanty/mutator.rb', line 18

def self.inherited(mutator)
  Util.logger.debug("Detected mutator #{mutator}")
  @mutators ||= []
  @mutators << mutator
end

Instance Method Details

#apply_mutationsObject



24
25
26
27
28
# File 'lib/shanty/mutator.rb', line 24

def apply_mutations
  self.class.mutators.each do |mutator|
    mutator.new(@env, @graph).mutate
  end
end