Sha256: dba2494fcddb757861b67eb23af4f326fc61b74a92a8d5a81da44bbdf36f41c5

Contents?: true

Size: 1.19 KB

Versions: 38

Compression:

Stored size: 1.19 KB

Contents

# The BaseBinding class is the base for all bindings.  It takes
# 4 arguments that should be passed up from the children (via super)
#
# 1. page - this class instance should provide:
#            - a #templates methods that returns a hash for templates
#            - an #events methods that returns an instance of DocumentEvents
# 2. target -  an DomTarget or AttributeTarget
# 3. context - the context object the binding will be evaluated in
# 4. binding_name - the id for the comment (or id for attributes) where the
#                   binding will be inserted.
module Volt
  class BaseBinding
    attr_accessor :target, :context, :binding_name

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

      @@binding_number ||= 10_000
    end

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

    def remove
      @dom_section.remove if @dom_section

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

    def remove_anchors
      @dom_section.remove_anchors if @dom_section
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
volt-0.9.3.pre1 lib/volt/page/bindings/base_binding.rb
volt-0.9.2 lib/volt/page/bindings/base_binding.rb
volt-0.9.1 lib/volt/page/bindings/base_binding.rb
volt-0.9.1.pre5 lib/volt/page/bindings/base_binding.rb
volt-0.9.1.pre4 lib/volt/page/bindings/base_binding.rb
volt-0.9.1.pre3 lib/volt/page/bindings/base_binding.rb
volt-0.9.1.pre2 lib/volt/page/bindings/base_binding.rb
volt-0.9.1.pre1 lib/volt/page/bindings/base_binding.rb
volt-0.9.0 lib/volt/page/bindings/base_binding.rb
volt-0.9.0.pre7 lib/volt/page/bindings/base_binding.rb
volt-0.9.0.pre6 lib/volt/page/bindings/base_binding.rb
volt-0.9.0.pre5 lib/volt/page/bindings/base_binding.rb
volt-0.9.0.pre4 lib/volt/page/bindings/base_binding.rb
volt-0.9.0.pre3 lib/volt/page/bindings/base_binding.rb
volt-0.9.0.pre2 lib/volt/page/bindings/base_binding.rb
volt-0.9.0.pre1 lib/volt/page/bindings/base_binding.rb
volt-0.8.27.beta9 lib/volt/page/bindings/base_binding.rb
volt-0.8.27.beta8 lib/volt/page/bindings/base_binding.rb
volt-0.8.27.beta7 lib/volt/page/bindings/base_binding.rb
volt-0.8.27.beta6 lib/volt/page/bindings/base_binding.rb