Class: Fiona7::Prefetch::WidgetResolverPrefetch

Inherits:
Object
  • Object
show all
Defined in:
lib/fiona7/prefetch/widget_resolver_prefetch.rb

Instance Method Summary collapse

Constructor Details

#initialize(klass, objects = []) ⇒ WidgetResolverPrefetch

Returns a new instance of WidgetResolverPrefetch.



8
9
10
11
12
# File 'lib/fiona7/prefetch/widget_resolver_prefetch.rb', line 8

def initialize(klass, objects=[])
  widget_object_ids = self.collect_widget_object_ids(objects)

  self.obj_prefetch = ObjPrefetch.new(klass, widget_object_ids)
end

Instance Method Details

#widget_resolver(object) ⇒ Object

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.



18
19
20
21
22
23
# File 'lib/fiona7/prefetch/widget_resolver_prefetch.rb', line 18

def widget_resolver(object)
  WidgetResolver.new(
    object.attr_values["X_widget_pool"]||[],
    self.obj_prefetch
  )
end