class Volt::BaseBinding

Attributes

binding_name[RW]
context[RW]
target[RW]
volt_app[RW]

Public Class Methods

new(volt_app, target, context, binding_name) click to toggle source
# File lib/volt/page/bindings/base_binding.rb, line 15
def initialize(volt_app, target, context, binding_name)
  @volt_app     = volt_app
  @target       = target
  @context      = context
  @binding_name = binding_name

  @@binding_number ||= 10_000
end

Public Instance Methods

browser() click to toggle source
# File lib/volt/page/bindings/base_binding.rb, line 24
def browser
  @volt_app.browser
end
dom_section() click to toggle source
# File lib/volt/page/bindings/base_binding.rb, line 28
def dom_section
  @dom_section ||= target.dom_section(@binding_name)
end
getter_fail(error) click to toggle source

log out a message about a failed computation or Promise.

# File lib/volt/page/bindings/base_binding.rb, line 46
def getter_fail(error)
  message = "#{self.class.to_s} Error: #{error.inspect}"

  if RUBY_PLATFORM == 'opal'
    if `#{@getter}`
      message += "\n" + `#{@getter}.toString()`
    end
  else
    if error.respond_to?(:backtrace)
      message += "\n" + error.backtrace.join("\n")
    end
  end

  Volt.logger.error(message)
end
remove() click to toggle source
# File lib/volt/page/bindings/base_binding.rb, line 32
def remove
  @dom_section.remove if @dom_section

  # Clear any references
  @target      = nil
  @context     = nil
  @dom_section = nil
end
remove_anchors() click to toggle source
# File lib/volt/page/bindings/base_binding.rb, line 41
def remove_anchors
  @dom_section.remove_anchors if @dom_section
end