module ActiveSerialize::Relation
Public Instance Methods
to_ha(*groups, pluck: [ ], plucked: nil, **args)
click to toggle source
# File lib/active_serialize/relation.rb, line 5 def to_ha(*groups, pluck: [ ], plucked: nil, **args) plucked ||= if pluck.is_a?(Proc) instance_eval(&pluck) else (_active_serialize[:pluck] + pluck).uniq.map { |key| [ key, instance_eval(&method(key)) ] }.to_h end if plucked.present? each_with_index.map do |record, i| record.to_h(*groups, plucked: plucked.each_key.map { |k| [ k, plucked[k][i] ] }.to_h, **args) end else map { |record| record.to_h(*groups, **args) } end end
with_ha(*args)
click to toggle source
# File lib/active_serialize/relation.rb, line 22 def with_ha(*args) return to_ha(*args), self end