Class: ContentBinding
Instance Attribute Summary
Attributes inherited from BaseBinding
#binding_name, #context, #target
Instance Method Summary
collapse
Methods inherited from BaseBinding
#dom_section, #remove_anchors
Constructor Details
#initialize(page, target, context, binding_name, getter) ⇒ ContentBinding
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/volt/page/bindings/content_binding.rb', line 4
def initialize(page, target, context, binding_name, getter)
super(page, target, context, binding_name)
@computation = -> do
begin
update(@context.instance_eval(&getter))
rescue => e
Volt.logger.error("ContentBinding Error: #{e.inspect}")
update('')
end
end.watch!
end
|
Instance Method Details
31
32
33
34
35
36
|
# File 'lib/volt/page/bindings/content_binding.rb', line 31
def remove
@computation.stop if @computation
@computation = nil
super
end
|
#update(value) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/volt/page/bindings/content_binding.rb', line 19
def update(value)
value = value.nil? ? '' : value
value = value.to_s
dom_section.html = value.gsub("\n", "<br />\n")
end
|