Sha256: a8231b4c9d0c05dc5dc192a9d7859102e1e0a96ee5bd0475784bdddfc82ca884
Contents?: true
Size: 986 Bytes
Versions: 7
Compression:
Stored size: 986 Bytes
Contents
require 'fiona7/prefetch/obj_prefetch' require 'fiona7/widget_resolver' require 'fiona7/widget_object_id_collector' module Fiona7 module Prefetch class WidgetResolverPrefetch def initialize(klass, objects=[]) widget_object_ids = self.collect_widget_object_ids(objects) self.obj_prefetch = ObjPrefetch.new(klass, widget_object_ids) end # Returns a widget resolver for given object. # If the object is already known to the prefetcher, # then widgets will be loaded from memory, # instead of database. def widget_resolver(object) WidgetResolver.new( object.attr_values["X_widget_pool"]||[], self.obj_prefetch ) end protected attr_accessor :obj_prefetch def collect_widget_object_ids(objects) objects.map do |object| WidgetObjectIdCollector.new(object.attr_values["X_widget_pool"]).call end.flatten.compact end end end end
Version data entries
7 entries across 7 versions & 1 rubygems