Class: Volt::BaseBinding
- Defined in:
- lib/volt/page/bindings/base_binding.rb
Direct Known Subclasses
AttributeBinding, ContentBinding, EachBinding, EventBinding, IfBinding, TemplateRenderer, ViewBinding, YieldBinding
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.
-
#volt_app ⇒ Object
Returns the value of attribute volt_app.
Instance Method Summary collapse
- #browser ⇒ Object
- #dom_section ⇒ Object
-
#getter_fail(error) ⇒ Object
log out a message about a failed computation or Promise.
-
#initialize(volt_app, target, context, binding_name) ⇒ BaseBinding
constructor
A new instance of BaseBinding.
- #remove ⇒ Object
- #remove_anchors ⇒ Object
Constructor Details
#initialize(volt_app, 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(volt_app, target, context, binding_name) @volt_app = volt_app @target = target @context = context @binding_name = binding_name @@binding_number ||= 10_000 end |
Instance Attribute Details
#binding_name ⇒ Object
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 |
#context ⇒ Object
Returns the value of attribute context.
13 14 15 |
# File 'lib/volt/page/bindings/base_binding.rb', line 13 def context @context end |
#target ⇒ Object
Returns the value of attribute target.
13 14 15 |
# File 'lib/volt/page/bindings/base_binding.rb', line 13 def target @target end |
#volt_app ⇒ Object
Returns the value of attribute volt_app.
13 14 15 |
# File 'lib/volt/page/bindings/base_binding.rb', line 13 def volt_app @volt_app end |
Instance Method Details
#browser ⇒ Object
24 25 26 |
# File 'lib/volt/page/bindings/base_binding.rb', line 24 def browser @volt_app.browser end |
#dom_section ⇒ Object
28 29 30 |
# File 'lib/volt/page/bindings/base_binding.rb', line 28 def dom_section @dom_section ||= target.dom_section(@binding_name) end |
#getter_fail(error) ⇒ Object
log out a message about a failed computation or Promise.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/volt/page/bindings/base_binding.rb', line 46 def getter_fail(error) = "#{self.class.to_s} Error: #{error.inspect}" if RUBY_PLATFORM == 'opal' if `#{@getter}` += "\n" + `#{@getter}.toString()` end else if error.respond_to?(:backtrace) += "\n" + error.backtrace.join("\n") end end Volt.logger.error() end |
#remove ⇒ Object
32 33 34 35 36 37 38 39 |
# 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 ⇒ Object
41 42 43 |
# File 'lib/volt/page/bindings/base_binding.rb', line 41 def remove_anchors @dom_section.remove_anchors if @dom_section end |