lib/fiona7/widget_resolver.rb in infopark_fiona7-1.2.0.0.1 vs lib/fiona7/widget_resolver.rb in infopark_fiona7-1.2.0.1.1

- old
+ new

@@ -1,25 +1,25 @@ module Fiona7 class WidgetResolver - def initialize(widget_pool_value, klass=WriteObj) - self.value = widget_pool_value - self.klass = klass + def initialize(widget_pool_value, obj_repository) + self.value = widget_pool_value + self.obj_repository = obj_repository - preload + self.preload end attr_reader :id_map, :path_map, :instance_map protected - attr_accessor :value, :klass + attr_accessor :value, :obj_repository attr_writer :id_map, :path_map, :instance_map def preload widget_id_to_object_id_map = Hash[ self.value.map {|link| [link["title"], link["destination"]] } ] object_id_to_widget_instance_map = Hash[ - self.klass.where(obj_id: widget_id_to_object_id_map.values).map {|obj| [obj.id, obj] } + self.obj_repository.find_many(widget_id_to_object_id_map.values).compact.map {|obj| [obj.id, obj] } ] self.id_map = widget_id_to_object_id_map.dup self.path_map = Hash[ widget_id_to_object_id_map.map {|widget_id, obj_id|