Module: Glimmer::DSL::BindExpression

Defined in:
lib/glimmer/dsl/bind_expression.rb

Overview

Responsible for setting up the return value of the bind keyword (command symbol) as a ModelBinding. It is to be used as the argument of another data-binding expression.

Instance Method Summary collapse

Instance Method Details

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

Returns:

  • (Boolean)

30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/glimmer/dsl/bind_expression.rb', line 30

def can_interpret?(parent, keyword, *args, &block)
  (
    keyword == 'bind' and
      (
        (
          (args.size == 2) and
            textual?(args[1])
        ) ||
          (
            (args.size == 3) and
              textual?(args[1]) and
              (args[2].is_a?(Hash))
          )
      )
  )
end

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


47
48
49
50
51
# File 'lib/glimmer/dsl/bind_expression.rb', line 47

def interpret(parent, keyword, *args, &block)
  binding_options = args[2] || {}
  binding_options[:on_read] = binding_options.delete(:on_read) || binding_options.delete('on_read') || block
  DataBinding::ModelBinding.new(args[0], args[1].to_s, binding_options)
end