Class: Volt::BaseBinding

Inherits:
Object show all
Defined in:
lib/volt/page/bindings/base_binding.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(page, target, context, binding_name) ⇒ BaseBinding

Returns a new instance of BaseBinding.



15
16
17
18
19
20
21
22
# File 'lib/volt/page/bindings/base_binding.rb', line 15

def initialize(page, target, context, binding_name)
  @page         = page
  @target       = target
  @context      = context
  @binding_name = binding_name

  @@binding_number ||= 10_000
end

Instance Attribute Details

#binding_nameObject

Returns the value of attribute binding_name.



13
14
15
# File 'lib/volt/page/bindings/base_binding.rb', line 13

def binding_name
  @binding_name
end

#contextObject

Returns the value of attribute context.



13
14
15
# File 'lib/volt/page/bindings/base_binding.rb', line 13

def context
  @context
end

#targetObject

Returns the value of attribute target.



13
14
15
# File 'lib/volt/page/bindings/base_binding.rb', line 13

def target
  @target
end

Instance Method Details

#dom_sectionObject



24
25
26
# File 'lib/volt/page/bindings/base_binding.rb', line 24

def dom_section
  @dom_section ||= target.dom_section(@binding_name)
end

#removeObject



28
29
30
31
32
33
34
35
# File 'lib/volt/page/bindings/base_binding.rb', line 28

def remove
  @dom_section.remove if @dom_section

  # Clear any references
  @target      = nil
  @context     = nil
  @dom_section = nil
end

#remove_anchorsObject



37
38
39
# File 'lib/volt/page/bindings/base_binding.rb', line 37

def remove_anchors
  @dom_section.remove_anchors if @dom_section
end