Class: Esse::Jbuilder::SearchRequestView

Inherits:
ActionView::Base
  • Object
show all
Defined in:
lib/esse/jbuilder/search_request_view.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(assings = {}) ⇒ SearchRequestView

Returns a new instance of SearchRequestView.



21
22
23
# File 'lib/esse/jbuilder/search_request_view.rb', line 21

def initialize(assings = {})
  super(self.class.lookup_context, assings, nil)
end

Class Method Details

.lookup_contextObject

Cache the LookupContext at the class level to avoid creating a new one per template render. LookupContext initializes file system resolvers, path sets, and detail hashes — expensive objects that are stateless relative to template assigns. Reusing it eliminates ~15K+ short-lived object graphs per minute under production traffic, reducing heap fragmentation that causes RSS growth over time.



12
13
14
15
16
17
18
19
# File 'lib/esse/jbuilder/search_request_view.rb', line 12

def self.lookup_context
  view_path = Esse.config.search_view_path
  if @lookup_context.nil? || @lookup_context_path != view_path
    @lookup_context_path = view_path
    @lookup_context = ::ActionView::LookupContext.new(view_path)
  end
  @lookup_context
end

Instance Method Details

#compiled_method_containerObject



25
26
27
# File 'lib/esse/jbuilder/search_request_view.rb', line 25

def compiled_method_container
  self.class
end