Class: Glimmer::DSL::Libui::CustomControlExpression

Inherits:
Expression
  • Object
show all
Includes:
ParentExpression, TopLevelExpression
Defined in:
lib/glimmer/dsl/libui/custom_control_expression.rb

Instance Method Summary collapse

Instance Method Details

#add_content(custom_control, keyword, *args, &block) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/glimmer/dsl/libui/custom_control_expression.rb', line 46

def add_content(custom_control, keyword, *args, &block)
  options = args.last.is_a?(Hash) ? args.last : {}
  options[:post_add_content] = true if !options.include?(:post_add_content)
  # TODO consider avoiding source_location
  if block.source_location == custom_control.content&.__getobj__&.source_location
    custom_control.content.call(custom_control) unless custom_control.content.called?
  else
    super
  end
  custom_control.post_add_content if options[:post_add_content]
end

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

Returns:

  • (Boolean)


37
38
39
# File 'lib/glimmer/dsl/libui/custom_control_expression.rb', line 37

def can_interpret?(parent, keyword, *args, &block)
  LibUI::CustomControl.for(keyword)
end

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



41
42
43
44
# File 'lib/glimmer/dsl/libui/custom_control_expression.rb', line 41

def interpret(parent, keyword, *args, &block)
  options = args.last.is_a?(Hash) ? args.pop : {}
  LibUI::CustomControl.for(keyword).new(keyword, parent, args, options, &block)
end