Sha256: 5738aadb9b7a82c4e6a1f41fbf76758315bebb9399c2376f46530c087b98ca13
Contents?: true
Size: 1.16 KB
Versions: 4
Compression:
Stored size: 1.16 KB
Contents
# typed: false # frozen_string_literal: true module Enumerable def where(options = {}) obj = first list = if obj.is_a?(::Hash) self else [] end Workato::Extension::Array::ArrayWhere.new(list, options || {}) end def format_map(format) if format.blank? return self end map do |val| format % (Array(val).map { |v| v.is_a?(HashWithIndifferentAccess) ? v.symbolize_keys : v }) end end def smart_join(separator) transform_select do |val| val = val.strip if val.is_a?(::String) val.presence end.join(separator) end def pluck(*keys) if keys.many? map { |element| keys.map { |key| element.respond_to?(:dig) ? element.dig(*key) : element[key] } } else map { |element| element.respond_to?(:dig) ? element.dig(*keys.first) : element[keys.first] } end end def transform_find(&block) each do |*items| result = block.call(*items) return result if result end nil end private def transform_select(&block) map do |*items| result = block.call(*items) result || nil end.reject(&:nil?) end end
Version data entries
4 entries across 4 versions & 1 rubygems