Class: ActionView::UnboundTemplate
- Defined in:
- actionview/lib/action_view/unbound_template.rb
Instance Attribute Summary collapse
-
#details ⇒ Object
readonly
Returns the value of attribute details.
-
#virtual_path ⇒ Object
readonly
Returns the value of attribute virtual_path.
Instance Method Summary collapse
- #bind_locals(locals) ⇒ Object
-
#built_templates ⇒ Object
:nodoc:.
-
#initialize(source, identifier, details:, virtual_path:) ⇒ UnboundTemplate
constructor
A new instance of UnboundTemplate.
Constructor Details
#initialize(source, identifier, details:, virtual_path:) ⇒ UnboundTemplate
Returns a new instance of UnboundTemplate.
10 11 12 13 14 15 16 17 18 |
# File 'actionview/lib/action_view/unbound_template.rb', line 10 def initialize(source, identifier, details:, virtual_path:) @source = source @identifier = identifier @details = details @virtual_path = virtual_path @templates = Concurrent::Map.new(initial_capacity: 2) @write_lock = Mutex.new end |
Instance Attribute Details
#details ⇒ Object (readonly)
Returns the value of attribute details
7 8 9 |
# File 'actionview/lib/action_view/unbound_template.rb', line 7 def details @details end |
#virtual_path ⇒ Object (readonly)
Returns the value of attribute virtual_path
7 8 9 |
# File 'actionview/lib/action_view/unbound_template.rb', line 7 def virtual_path @virtual_path end |
Instance Method Details
#bind_locals(locals) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'actionview/lib/action_view/unbound_template.rb', line 20 def bind_locals(locals) unless template = @templates[locals] @write_lock.synchronize do normalized_locals = normalize_locals(locals) # We need ||=, both to dedup on the normalized locals and to check # while holding the lock. template = (@templates[normalized_locals] ||= build_template(normalized_locals)) # This may have already been assigned, but we've already de-dup'd so # reassignment is fine. @templates[locals.dup] = template if template.strict_locals? # Under strict locals, we only need one template. # This replaces the @templates Concurrent::Map with a hash which # returns this template for every key. @templates = Hash.new(template).freeze end end end template end |
#built_templates ⇒ Object
:nodoc:
44 45 46 |
# File 'actionview/lib/action_view/unbound_template.rb', line 44 def built_templates # :nodoc: @templates.values end |