Class: Glimmer::DSL::Libui::CustomShapeExpression

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

Instance Method Summary collapse

Instance Method Details

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



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

def add_content(custom_shape, 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_shape.content&.__getobj__&.source_location
    custom_shape.content.call(custom_shape) unless custom_shape.content.called?
  else
    super
  end
  custom_shape.post_add_content if options[:post_add_content]
end

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

Returns:

  • (Boolean)


36
37
38
# File 'lib/glimmer/dsl/libui/custom_shape_expression.rb', line 36

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

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



40
41
42
43
# File 'lib/glimmer/dsl/libui/custom_shape_expression.rb', line 40

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