Sha256: 8f56476aef590d627213b3d04a597f80556269b748af20d9015c215b6241998d
Contents?: true
Size: 661 Bytes
Versions: 1
Compression:
Stored size: 661 Bytes
Contents
# frozen_string_literal: true module ActiveSerialize module Relation def to_ha(pluck: [ ], plucked: nil, **args) plucked ||= if pluck.is_a?(Proc) instance_eval(&pluck) else (_active_serialize[:pluck] + pluck).map { |key| [ key, instance_eval(&method(key)) ] }.to_h end if plucked.present? each_with_index.map do |record, i| record.to_h(plucked: plucked.each_key.map { |k| [ k, plucked[k][i] ] }.to_h, **args) end else map { |record| record.to_h(**args) } end end def with_ha(*args) return to_ha(*args), self end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_serialize-2.4.0 | lib/active_serialize/relation.rb |