Sha256: 904609282b80ed8bc40239f03c20fc495077293e90daf40a3f16082800c5bbc0
Contents?: true
Size: 868 Bytes
Versions: 2
Compression:
Stored size: 868 Bytes
Contents
module Representable Pipeline.class_eval do # FIXME: this doesn't define Function in Pipeline. module Function class Insert def call(arr, func, options) arr = arr.dup delete!(arr, func) if options[:delete] replace!(arr, options[:replace], func) if options[:replace] arr end private def replace!(arr, old_func, new_func) arr.each_with_index { |func, index| if func.is_a?(Collect) arr[index] = Collect[*Pipeline::Insert.(func, new_func, replace: old_func)] end arr[index] = new_func if old_func.is_a?(Proc)? (func==old_func) : old_func.instance_of?(func.class) } end def delete!(arr, func) arr.delete(func) end end end end Pipeline::Insert = Function::Insert.new end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
representable-2.4.0.rc2 | lib/representable/insert.rb |
representable-2.4.0.rc1 | lib/representable/insert.rb |