Class: Wallaby::View::CustomLookupContext
- Inherits:
-
ActionView::LookupContext
- Object
- ActionView::LookupContext
- Wallaby::View::CustomLookupContext
- Defined in:
- lib/wallaby/view/custom_lookup_context.rb
Overview
Custom lookup context to cache lookup results.
Class Method Summary collapse
-
.convert(lookup_context, details: nil, prefixes: nil) ⇒ CustomLookupContext
Convert an ActionView::LookupContext instance into CustomLookupContext.
Instance Method Summary collapse
-
#find(path, prefixes, partial, *args) ⇒ ActionView::Template
(also: #find_template)
This is to resolve the performance bottleneck for template/partial lookup.
-
#original_find(path, prefixes, partial, *args) ⇒ ActionView::Template
Original find method.
Class Method Details
.convert(lookup_context, details: nil, prefixes: nil) ⇒ CustomLookupContext
Convert an ActionView::LookupContext instance into Wallaby::View::CustomLookupContext
12 13 14 15 16 17 18 19 20 |
# File 'lib/wallaby/view/custom_lookup_context.rb', line 12 def self.convert(lookup_context, details: nil, prefixes: nil) return lookup_context if lookup_context.is_a? self new( lookup_context.view_paths, details || lookup_context.instance_variable_get('@details'), prefixes || lookup_context.prefixes ) end |
Instance Method Details
#find(path, prefixes, partial, *args) ⇒ ActionView::Template Also known as: find_template
This is to resolve the performance bottleneck for template/partial lookup.
#cached_lookup is used to cache the lookup result throughout a request.
39 40 41 42 |
# File 'lib/wallaby/view/custom_lookup_context.rb', line 39 def find(path, prefixes, partial, *args) key = [path, prefixes, partial].join(EQUAL) cached_lookup[key] ||= original_find(path, prefixes, partial, *args) end |
#original_find(path, prefixes, partial, *args) ⇒ ActionView::Template
Original find method.
29 |
# File 'lib/wallaby/view/custom_lookup_context.rb', line 29 alias original_find find |