module Card::View::Cache::Stub
A “stub” is a placeholder for a card view.
Cached views use stubs so that nesting content can remained cached even while nested content changes. The nested content’s place is held by a stub.
A stub must contain all the information necessary to produce the view as intended.
Private Instance Methods
Source
# File lib/card/view/cache/stub.rb, line 19 def bin_to_hex string string.unpack1("H*") end
Source
# File lib/card/view/cache/stub.rb, line 15 def stub "(StUb#{stub_hash.to_json}sTuB)".html_safe end
@return [String]
Source
# File lib/card/view/cache/stub.rb, line 38 def stub_cast cast = card.cast cast.delete :content if cast[:content].nil? cast end
Source
# File lib/card/view/cache/stub.rb, line 24 def stub_hash { cast: stub_cast, view_opts: normalized_options.merge(normalized_visibility_options), format_opts: { nest_mode: format.nest_mode, override: root?, context_names: format.context_names } } # nest mode handling: # # Typically modes override views on nests, but stubs create non-standard nests. # Mode-based view overrides should NOT apply to standard render calls that have # been replaced with stubs - only to standard nest calls. The override value # is used to retain this distinction. end
@return [Hash]