Sha256: f15ab44b12addb43cb9777325076ef7b9ba21840aaa929077da4512941aa0b8d

Contents?: true

Size: 1.25 KB

Versions: 43

Compression:

Stored size: 1.25 KB

Contents

require 'glimmer/dsl/static_expression'
require 'glimmer/data_binding/model_binding'

module Glimmer
  module DSL
    module SWT
      # Responsible for setting up the return value of the bind keyword (command symbol)
      # as a ModelBinding. It is then used by another command handler like
      # DataBindingCommandHandler for text and selection properties on Text and Spinner
      # or TableItemsDataBindingCommandHandler for items in a Table
      class BindExpression < StaticExpression
        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
  
        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
      end
    end
  end
end

Version data entries

43 entries across 43 versions & 2 rubygems

Version Path
glimmer-dsl-swt-0.6.9 lib/glimmer/dsl/swt/bind_expression.rb
glimmer-dsl-swt-0.6.8 lib/glimmer/dsl/swt/bind_expression.rb
glimmer-dsl-swt-0.6.7 lib/glimmer/dsl/swt/bind_expression.rb
glimmer-dsl-swt-0.6.6 lib/glimmer/dsl/swt/bind_expression.rb
glimmer-dsl-swt-0.6.5 lib/glimmer/dsl/swt/bind_expression.rb
glimmer-dsl-swt-0.6.4 lib/glimmer/dsl/swt/bind_expression.rb
glimmer-dsl-swt-0.6.3 lib/glimmer/dsl/swt/bind_expression.rb
glimmer-dsl-swt-0.6.2 lib/glimmer/dsl/swt/bind_expression.rb
glimmer-dsl-swt-0.6.1 lib/glimmer/dsl/swt/bind_expression.rb
glimmer-dsl-swt-0.6.0 lib/glimmer/dsl/swt/bind_expression.rb
glimmer-dsl-swt-0.5.6 lib/glimmer/dsl/swt/bind_expression.rb
glimmer-dsl-swt-0.5.5 lib/glimmer/dsl/swt/bind_expression.rb
glimmer-dsl-swt-0.5.4 lib/glimmer/dsl/swt/bind_expression.rb
glimmer-dsl-swt-0.5.3 lib/glimmer/dsl/swt/bind_expression.rb
glimmer-dsl-swt-0.5.2 lib/glimmer/dsl/swt/bind_expression.rb
glimmer-dsl-swt-0.5.1 lib/glimmer/dsl/swt/bind_expression.rb
glimmer-dsl-swt-0.5.0 lib/glimmer/dsl/swt/bind_expression.rb
glimmer-dsl-swt-0.4.1 lib/glimmer/dsl/swt/bind_expression.rb
glimmer-dsl-swt-0.4.0 lib/glimmer/dsl/swt/bind_expression.rb
glimmer-dsl-swt-0.3.1 lib/glimmer/dsl/swt/bind_expression.rb