Class: Glimmer::DSL::SWT::TreeItemsDataBindingExpression

Inherits:
Expression
  • Object
show all
Defined in:
lib/glimmer/dsl/swt/tree_items_data_binding_expression.rb

Instance Method Summary collapse

Instance Method Details

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

Returns:

  • (Boolean)


32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/glimmer/dsl/swt/tree_items_data_binding_expression.rb', line 32

def can_interpret?(parent, keyword, *args, &block)
  keyword == 'items' and
    block.nil? and
    parent.respond_to?(:swt_widget) and
    parent.swt_widget.is_a?(Tree) and
    args.size.between?(1, 2)
  # TODO delete these checks if they are too granular
#           return false unless initial_condition
#           raise Glimmer::Error, 'Tree items args must be 1 or 2' unless args.size.between?(1, 2)
#           raise Glimmer::Error, 'Tree items first arg must be a bind expression' unless args[0].is_a?(DataBinding::ModelBinding)
#           raise Glimmer::Error, 'Tree items data-binding initial value must not be an array yet a single item representing tree root' unless !args[0].evaluate_property.is_a?(Array)
#           raise Glimmer::Error, 'Tree items second arg must be an array' unless args[1].is_a?(Array)
#           raise Glimmer::Error, 'Tree items second arg must not be empty' unless !args[1].empty?
#           raise Glimmer::Error, 'Tree items second arg array elements must be of type hash' unless args[1].first.is_a?(Hash)
#           true
end

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



49
50
51
52
53
# File 'lib/glimmer/dsl/swt/tree_items_data_binding_expression.rb', line 49

def interpret(parent, keyword, *args, &block)
  model_binding = args[0]
  tree_properties = args[1]
  DataBinding::TreeItemsBinding.new(parent, model_binding, tree_properties)
end