Class: Glimmer::DSL::Tk::DataBindingExpression
- Inherits:
-
Expression
- Object
- Expression
- Glimmer::DSL::Tk::DataBindingExpression
- Defined in:
- lib/glimmer/dsl/tk/data_binding_expression.rb
Overview
Responsible for wiring two-way data-binding. Does so by using the output of the bind(model, property) command in the form of a ModelBinding, which is then connected to an anonymous widget observer
Depends on BindCommandHandler
Instance Method Summary collapse
- #can_interpret?(parent, keyword, *args, &block) ⇒ Boolean
- #interpret(parent, keyword, *args, &block) ⇒ Object
Instance Method Details
#can_interpret?(parent, keyword, *args, &block) ⇒ Boolean
35 36 37 38 |
# File 'lib/glimmer/dsl/tk/data_binding_expression.rb', line 35 def can_interpret?(parent, keyword, *args, &block) args.size == 1 and args[0].is_a?(DataBinding::ModelBinding) end |
#interpret(parent, keyword, *args, &block) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/glimmer/dsl/tk/data_binding_expression.rb', line 40 def interpret(parent, keyword, *args, &block) model_binding = args[0] = [parent, keyword] = DataBinding::Tk::WidgetBinding.new(*) #TODO make this options observer dependent and all similar observers in widget specific data binding handlers registration = .observe(model_binding) parent.on('destroy') { registration.deregister } # TODO simplify this logic and put it where it belongs parent.add_observer(model_binding, keyword) if parent.respond_to?(:add_observer, [model_binding, keyword]) .call(model_binding.evaluate_property) end |