Class: Gloo::Expr::Call
- Inherits:
-
Object
- Object
- Gloo::Expr::Call
- Defined in:
- lib/gloo/expr/call.rb
Instance Attribute Summary collapse
-
#arg_tokens ⇒ Object
readonly
Returns the value of attribute arg_tokens.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Class Method Summary collapse
-
.call?(token) ⇒ Boolean
Does the given token look like an inline call?.
Instance Method Summary collapse
-
#initialize(engine, token) ⇒ Call
constructor
Parse the call token into a target path and raw arg tokens.
-
#value ⇒ Object
Resolve, validate and invoke - returns the result value, or nil if it failed (an error will already have been reported).
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_tokens ⇒ Object (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 |
#target ⇒ Object (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?
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 |