Module: Glimmer::DSL::SWT::ExecExpression

Includes:
TopLevelExpression
Included in:
AsyncExecExpression, AutoExecExpression, SyncExecExpression, TimerExecExpression
Defined in:
lib/glimmer/dsl/swt/exec_expression.rb

Overview

Mixin for common code in async_exec and sync_exec expressions Uses name in subclass to auto-derive exec_operation

Instance Method Summary collapse

Instance Method Details

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

Returns:

  • (Boolean)


37
38
39
40
41
# File 'lib/glimmer/dsl/swt/exec_expression.rb', line 37

def can_interpret?(parent, keyword, *args, &block)
  keyword == exec_operation and
    block_given? and
    args.empty?
end

#exec_operationObject



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

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

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



43
44
45
46
47
48
49
50
51
# File 'lib/glimmer/dsl/swt/exec_expression.rb', line 43

def interpret(parent, keyword, *args, &block)
  Glimmer::SWT::DisplayProxy.instance.send(exec_operation, *args) do |*args|
    begin
      block.call(*args)
    rescue => e
      Glimmer::Config.logger.error {e.full_message}
    end
  end
end