Class: Twig::Callable
- Inherits:
-
Object
- Object
- Twig::Callable
- Defined in:
- lib/twig/callable.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#arguments ⇒ Object
Returns the value of attribute arguments.
-
#callable ⇒ Object
readonly
Returns the value of attribute callable.
-
#dynamic_name ⇒ Object
Returns the value of attribute dynamic_name.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name, callable = nil, options = {}) ⇒ Callable
constructor
A new instance of Callable.
- #needs_charset? ⇒ Boolean
- #needs_context? ⇒ Boolean
- #needs_environment? ⇒ Boolean
- #type ⇒ Object
- #with_dynamic_arguments(name, dynamic_name, arguments) ⇒ Object
Constructor Details
#initialize(name, callable = nil, options = {}) ⇒ Callable
Returns a new instance of Callable.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/twig/callable.rb', line 11 def initialize(name, callable = nil, = {}) @name = @dynamic_name = name @arguments = [] @callable = callable @options = { needs_environment: false, needs_context: false, needs_charset: false, is_variadic: false, }.merge() end |
Instance Attribute Details
#arguments ⇒ Object
Returns the value of attribute arguments.
6 7 8 |
# File 'lib/twig/callable.rb', line 6 def arguments @arguments end |
#callable ⇒ Object (readonly)
Returns the value of attribute callable.
5 6 7 |
# File 'lib/twig/callable.rb', line 5 def callable @callable end |
#dynamic_name ⇒ Object
Returns the value of attribute dynamic_name.
6 7 8 |
# File 'lib/twig/callable.rb', line 6 def dynamic_name @dynamic_name end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/twig/callable.rb', line 6 def name @name end |
Instance Method Details
#needs_charset? ⇒ Boolean
27 28 29 |
# File 'lib/twig/callable.rb', line 27 def needs_charset? @options[:needs_charset] end |
#needs_context? ⇒ Boolean
35 36 37 |
# File 'lib/twig/callable.rb', line 35 def needs_context? @options[:needs_context] end |
#needs_environment? ⇒ Boolean
31 32 33 |
# File 'lib/twig/callable.rb', line 31 def needs_environment? @options[:needs_environment] end |
#type ⇒ Object
23 24 25 |
# File 'lib/twig/callable.rb', line 23 def type raise NotImplementedError end |
#with_dynamic_arguments(name, dynamic_name, arguments) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/twig/callable.rb', line 39 def with_dynamic_arguments(name, dynamic_name, arguments) new = clone new.name = name new.dynamic_name = dynamic_name new.arguments = arguments new end |