Class: BaseBinding
Overview
The BaseBinding class is the base for all bindings. It takes 4 arguments that should be passed up from the children (via super)
-
page - this class instance should provide:
- a #templates methods that returns a hash for templates - an #events methods that returns an instance of DocumentEvents
-
target - an DomTarget or AttributeTarget
-
context - the context object the binding will be evaluated in
-
binding_name - the id for the comment (or id for attributes) where the
binding will be inserted.
Direct Known Subclasses
AttributeBinding, ContentBinding, EachBinding, EventBinding, IfBinding, TemplateBinding, TemplateRenderer
Instance Attribute Summary collapse
-
#binding_name ⇒ Object
Returns the value of attribute binding_name.
-
#context ⇒ Object
Returns the value of attribute context.
-
#target ⇒ Object
Returns the value of attribute target.
Instance Method Summary collapse
-
#initialize(page, target, context, binding_name) ⇒ BaseBinding
constructor
A new instance of BaseBinding.
- #queue_update ⇒ Object
- #remove ⇒ Object
- #remove_anchors ⇒ Object
- #section ⇒ Object
- #value_from_getter(getter) ⇒ Object
Constructor Details
#initialize(page, target, context, binding_name) ⇒ BaseBinding
Returns a new instance of BaseBinding.
14 15 16 17 18 19 20 21 22 |
# File 'lib/volt/page/bindings/base_binding.rb', line 14 def initialize(page, target, context, binding_name) # puts "NEW #{context.inspect} - #{self.inspect}" @page = page @target = target @context = context @binding_name = binding_name @@binding_number ||= 10000 end |
Instance Attribute Details
#binding_name ⇒ Object
Returns the value of attribute binding_name.
12 13 14 |
# File 'lib/volt/page/bindings/base_binding.rb', line 12 def binding_name @binding_name end |
#context ⇒ Object
Returns the value of attribute context.
12 13 14 |
# File 'lib/volt/page/bindings/base_binding.rb', line 12 def context @context end |
#target ⇒ Object
Returns the value of attribute target.
12 13 14 |
# File 'lib/volt/page/bindings/base_binding.rb', line 12 def target @target end |
Instance Method Details
#queue_update ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/volt/page/bindings/base_binding.rb', line 41 def queue_update if Volt.server? # Run right away update else end end |
#remove ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/volt/page/bindings/base_binding.rb', line 28 def remove section.remove # Clear any references @target = nil @context = nil @section = nil end |
#remove_anchors ⇒ Object
37 38 39 |
# File 'lib/volt/page/bindings/base_binding.rb', line 37 def remove_anchors section.remove_anchors end |
#section ⇒ Object
24 25 26 |
# File 'lib/volt/page/bindings/base_binding.rb', line 24 def section @section ||= target.section(@binding_name) end |
#value_from_getter(getter) ⇒ Object
50 51 52 53 |
# File 'lib/volt/page/bindings/base_binding.rb', line 50 def value_from_getter(getter) # Evaluate the getter proc in the context return @context.instance_eval(&getter) end |