Class: Glimmer::DSL::StaticExpression

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

Overview

Represents a StaticExpression for expressions where the keyword does not vary dynamically. These static keywords are then predefined as methods in Glimmer instead of needing method_missing

StaticExpression subclasses may optionally implement ‘#can_interpret?` (not needed if it only checks for keyword)

StaticExpression subclasses must define ‘#interpret`.

The direct parent namespace of a StaticExpression subclass must match the DSL name (case-insensitive) (e.g. Glimmer::DSL::SWT::WidgetExpression has a DSL of :swt)

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Expression

#add_content, dsl, #interpret, #textual?

Class Method Details

.inherited(base) ⇒ Object



22
23
24
25
# File 'lib/glimmer/dsl/static_expression.rb', line 22

def inherited(base)
  Glimmer::DSL::Engine.add_static_expression(base.new)
  super
end

.keywordObject



27
28
29
# File 'lib/glimmer/dsl/static_expression.rb', line 27

def keyword
  @keyword ||= name.split(/::/).last.sub(/Expression$/, '').underscore
end

Instance Method Details

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

Subclasses may optionally implement

Returns:

  • (Boolean)


33
34
35
# File 'lib/glimmer/dsl/static_expression.rb', line 33

def can_interpret?(parent, keyword, *args, &block)
  true
end