Class: Hermod::InputMutator

Inherits:
Object
  • Object
show all
Defined in:
lib/hermod/input_mutator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mutator_proc) ⇒ InputMutator

Returns a new instance of InputMutator.



5
6
7
# File 'lib/hermod/input_mutator.rb', line 5

def initialize(mutator_proc)
  @mutator_proc = mutator_proc
end

Instance Attribute Details

#mutator_procObject (readonly)

Returns the value of attribute mutator_proc.



3
4
5
# File 'lib/hermod/input_mutator.rb', line 3

def mutator_proc
  @mutator_proc
end

Instance Method Details

#mutate!(values, attributes, instance) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/hermod/input_mutator.rb', line 9

def mutate!(values, attributes, instance)
  if mutator_proc.arity == 2
    mutator_proc.call(values, attributes)
  else
    mutator_proc.call(values, attributes, instance)
  end
end