Class: SerializeExtraContainerValues::AltRenderCalculator

Inherits:
Object
  • Object
show all
Defined in:
backend/app/exporters/lib/serialize_extra_container_values.rb

Instance Method Summary (collapse)

Constructor Details

- (AltRenderCalculator) initialize

Returns a new instance of AltRenderCalculator



6
7
8
# File 'backend/app/exporters/lib/serialize_extra_container_values.rb', line 6

def initialize
  @lookup_cache = Rufus::Lru::Hash.new(128)
end

Instance Method Details

- (Object) for_top_container_uri(uri)



10
11
12
13
14
15
16
17
18
19
# File 'backend/app/exporters/lib/serialize_extra_container_values.rb', line 10

def for_top_container_uri(uri)
  @lookup_cache.fetch(uri) {
    top_container_id = JSONModel::JSONModel(:top_container).id_for(uri)
    profile = TopContainer.any_repo[top_container_id].related_records(:top_container_profile)

    if profile
      @lookup_cache[uri] = (profile.url || profile.name)
    end
  }
end