Module: Lab42::Function::ParamsReorderer

Extended by:
ParamsReorderer
Included in:
ParamsReorderer
Defined in:
lib/lab42/function/params_reorderer.rb

Instance Method Summary collapse

Instance Method Details

#combine_and_reorder(first_stage_params, second_stage_params) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/lab42/function/params_reorderer.rb', line 3

def combine_and_reorder first_stage_params, second_stage_params
  store = Hash[*second_stage_params.each_with_index.to_a.flatten.reverse]
  first_stage_params.map{ | fst_param |
    case fst_param
    when Lab42::Function::Placeholder
      fetch_and_delete store, fst_param.arg_number.pred
    else
      fst_param
    end
  } + store.to_a.sort_by(&:first).map(&:last)
end