Class: Xavier::Mutator Private
- Inherits:
-
Object
- Object
- Xavier::Mutator
- Defined in:
- lib/xavier/mutator.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Applies and unapplies state mutations to objects.
Instance Method Summary collapse
-
#apply_state(from:, to:, strategies:) ⇒ Array
private
Applies the given
state
to the givenobservable
. -
#create_state_from(observable, strategies:) ⇒ State
private
Returns a state representation from a given
observable
. -
#mutation_strategies_for(observable) ⇒ Array
private
Finds the mutation mutation_strategies for a given
observable
.
Instance Method Details
#apply_state(from:, to:, strategies:) ⇒ Array
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Applies the given state
to the given observable
.
31 32 33 |
# File 'lib/xavier/mutator.rb', line 31 def apply_state(from:, to:, strategies:) strategies.each { |strategy| strategy.copy(from: from, to: to) } end |
#create_state_from(observable, strategies:) ⇒ State
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a state representation from a given observable
.
18 19 20 21 22 |
# File 'lib/xavier/mutator.rb', line 18 def create_state_from(observable, strategies:) state = State.new(observable.object_id) strategies.each { |strategy| strategy.copy(from: observable, to: state) } state end |
#mutation_strategies_for(observable) ⇒ Array
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Finds the mutation mutation_strategies for a given observable
.
40 41 42 43 44 |
# File 'lib/xavier/mutator.rb', line 40 def mutation_strategies_for(observable) [MutationStrategies::InstanceCopy].tap do |strategies| strategies.push(MutationStrategies::ClassCopy) if observable.is_a?(Class) end end |