Class: Twig::Node::Expression::Test::Defined
- Inherits:
-
Test::Base
- Object
- Test::Base
- Twig::Node::Expression::Test::Defined
- Defined in:
- lib/twig/node/expression/test/defined.rb
Overview
Checks if an expression is defined
var is defined }
Instance Method Summary collapse
- #compile(compiler) ⇒ Object
-
#initialize(node, name, arguments, lineno) ⇒ Defined
constructor
A new instance of Defined.
Constructor Details
#initialize(node, name, arguments, lineno) ⇒ Defined
Returns a new instance of Defined.
15 16 17 18 19 20 21 22 23 |
# File 'lib/twig/node/expression/test/defined.rb', line 15 def initialize(node, name, arguments, lineno) unless node.is_a?(SupportDefinedTest) raise Error::Syntax.new('The "defined" test only works with simple variables.', lineno) end node.enable_defined_test super end |
Instance Method Details
#compile(compiler) ⇒ Object
25 26 27 28 |
# File 'lib/twig/node/expression/test/defined.rb', line 25 def compile(compiler) compiler. subcompile(nodes[:node]) end |