Class: Glimmer::DSL::Web::DataBindingExpression

Inherits:
Expression
  • Object
show all
Defined in:
lib/glimmer/dsl/web/data_binding_expression.rb

Overview

Responsible for wiring two-way data-binding for text and selection properties on Text, Button, and Spinner elements. 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 element observer (aka element_data_binder as per element_data_binders array)

Depends on BindCommandHandler

Instance Method Summary collapse

Instance Method Details

#can_interpret?(parent, keyword, *args, &block) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
20
# File 'lib/glimmer/dsl/web/data_binding_expression.rb', line 16

def can_interpret?(parent, keyword, *args, &block)
  args.size == 1 and
    args[0].is_a?(DataBinding::ModelBinding) and
    parent.respond_to?(:data_bind)
end

#interpret(parent, keyword, *args, &block) ⇒ Object



22
23
24
25
26
# File 'lib/glimmer/dsl/web/data_binding_expression.rb', line 22

def interpret(parent, keyword, *args, &block)
  model_binding = args[0]
  property = keyword
  parent.data_bind(property, model_binding)
end