Sha256: 705ecd59a9f797bedd185295b4aac44fb7991f76cb01891a14aa98dd81c61007
Contents?: true
Size: 593 Bytes
Versions: 9
Compression:
Stored size: 593 Bytes
Contents
require 'fiona7/attribute_writers/attribute_writer' module Fiona7 module AttributeWriters class ReferencelistAsLinklist < AttributeWriter def call(value, claimed_type=nil) # FIXME: use a repository to improve performance ids = (value || []).map(&:to_s) if ids.empty? self.obj.set(self.attr_name, []) else objects_map = Hash[self.klass.where(obj_id: ids).map {|o| [o.id.to_s, o]}] objects = ids.map {|id| objects_map[id] }.compact self.obj.set(self.attr_name, objects) end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems