Class: DevelopWithPassion::Expander::ArrayMutatorStep

Inherits:
Object
  • Object
show all
Defined in:
lib/developwithpassion_expander/array_mutator_step.rb

Instance Method Summary collapse

Instance Method Details

#run_using(builder) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/developwithpassion_expander/array_mutator_step.rb', line 4

def run_using(builder)
Module.new do
  builder.mutators.each do|mutator|
    define_method(mutator.name) do|value|
      array_var = instance_variable_get("@#{builder.name}")
      array_var.push(value) unless mutator.block
      mutator.block.call(value) if mutator.block
    end
  end
end
end