Class: Gloo::Expr::Call

Inherits:
Object
  • Object
show all
Defined in:
lib/gloo/expr/call.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(engine, token) ⇒ Call

Parse the call token into a target path and raw arg tokens.



35
36
37
38
39
40
41
42
# File 'lib/gloo/expr/call.rb', line 35

def initialize( engine, token )
  @engine = engine

  inner = token[ token.index( '(' ) + 1..-2 ].to_s
  tokens = Gloo::Core::Tokens.new( inner )
  @target = tokens.first
  @arg_tokens = tokens.params || []
end

Instance Attribute Details

#arg_tokensObject (readonly)

Returns the value of attribute arg_tokens.



19
20
21
# File 'lib/gloo/expr/call.rb', line 19

def arg_tokens
  @arg_tokens
end

#targetObject (readonly)

Returns the value of attribute target.



19
20
21
# File 'lib/gloo/expr/call.rb', line 19

def target
  @target
end

Class Method Details

.call?(token) ⇒ Boolean

Does the given token look like an inline call?

Returns:

  • (Boolean)


24
25
26
27
28
29
30
# File 'lib/gloo/expr/call.rb', line 24

def self.call?( token )
  return false unless token.is_a?( String )

  return Gloo::Core::Tokens::CALL_OPENERS.any? do |kw|
    token.start_with?( "#{kw}(" ) && token.end_with?( ')' )
  end
end

Instance Method Details

#valueObject

Resolve, validate and invoke - returns the result value, or nil if it failed (an error will already have been reported).



48
49
50
# File 'lib/gloo/expr/call.rb', line 48

def value
  return Gloo::Core::Invoker.invoke( @engine, @target, @arg_tokens )
end