class Glimmer::DSL::Tk::DataBindingExpression
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
Public Instance Methods
can_interpret?(parent, keyword, *args, &block)
click to toggle source
# 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)
click to toggle source
# File lib/glimmer/dsl/tk/data_binding_expression.rb, line 40 def interpret(parent, keyword, *args, &block) parent.class model_binding = args[0] widget_binding_parameters = [parent, keyword] widget_binding = DataBinding::Tk::WidgetBinding.new(*widget_binding_parameters) #TODO make this options observer dependent and all similar observers in widget specific data binding handlers widget_binding.observe(model_binding) # 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]) widget_binding.call(model_binding.evaluate_property) end