Sha256: b1b8026fb7bd0f7d1f6f7687c1f52431e0a45f73a1dcea3e54fb23003d8e0270
Contents?: true
Size: 655 Bytes
Versions: 3
Compression:
Stored size: 655 Bytes
Contents
# frozen_string_literal: true # # Copyright (c) 2020-present, Blue Marble Payroll, LLC # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. # module Realize class Collection # Transformer to get an item of a collection class AtIndex acts_as_hashable attr_reader :index def initialize(index:) raise ArgumentError, 'index is required' if index.to_s.empty? @index = index.to_i freeze end def transform(_resolver, value, _time, _record) value.is_a?(Array) ? value[index] : value end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
realize-1.6.0 | lib/realize/collection/at_index.rb |
realize-1.5.0 | lib/realize/collection/at_index.rb |
realize-1.4.0 | lib/realize/collection/at_index.rb |