Sha256: a9c44bbb8a826b5c855fe204b43bab3366965bc5f0e4e7fe17bc908b5e99087b
Contents?: true
Size: 617 Bytes
Versions: 10
Compression:
Stored size: 617 Bytes
Contents
# frozen_string_literal: true module Pipeable module Steps # Inserts elements before or after an object. class Insert < Abstract LAST = -1 def initialize(*positionals, at: LAST, **) super(*positionals, **) @value = positionals.empty? ? base_keywords : positionals.flatten @at = at end def call result result.fmap do |object| cast = object.is_a?(Array) ? object : [object] value.is_a?(Array) ? cast.insert(at, *value) : cast.insert(at, value) end end private attr_reader :value, :at end end end
Version data entries
10 entries across 10 versions & 1 rubygems