Class: Twig::TwigTest

Inherits:
Callable show all
Defined in:
lib/twig/twig_test.rb

Instance Attribute Summary

Attributes inherited from Callable

#arguments, #callable, #dynamic_name, #name

Instance Method Summary collapse

Methods inherited from Callable

#needs_charset?, #needs_environment?, #with_dynamic_arguments

Constructor Details

#initialize(name, callable = nil, options = {}) ⇒ TwigTest

Returns a new instance of TwigTest.



5
6
7
8
9
10
11
12
# File 'lib/twig/twig_test.rb', line 5

def initialize(name, callable = nil, options = {})
  super

  @options = {
    node_class: Node::Expression::Test::Base,
    one_mandatory_argument: false,
  }.merge(@options)
end

Instance Method Details

#needs_context?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/twig/twig_test.rb', line 27

def needs_context?
  false
end

#node_classObject



18
19
20
# File 'lib/twig/twig_test.rb', line 18

def node_class
  @options[:node_class]
end

#one_mandatory_argument?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/twig/twig_test.rb', line 23

def one_mandatory_argument?
  @options[:one_mandatory_argument]
end

#typeObject



14
15
16
# File 'lib/twig/twig_test.rb', line 14

def type
  :test
end