Class: Dentaku::AST::Enum
- Defined in:
- lib/dentaku/ast/functions/enum.rb
Constant Summary
Constants inherited from Function
Constants inherited from Node
Node::STATIC_CONTEXT, Node::STATIC_MODE_KEY
Instance Attribute Summary
Attributes inherited from Function
Class Method Summary collapse
Instance Method Summary collapse
- #dependencies(context = {}) ⇒ Object
-
#initialize(*args) ⇒ Enum
constructor
A new instance of Enum.
- #validate_identifier(arg, message = "#{name}() requires second argument to be an identifier") ⇒ Object
Methods inherited from Function
#accept, get, register, register_class, registry, volatile?
Methods inherited from Node
arity, #name, precedence, #pure?, resolve_class, #type
Constructor Details
#initialize(*args) ⇒ Enum
Returns a new instance of Enum.
15 16 17 18 |
# File 'lib/dentaku/ast/functions/enum.rb', line 15 def initialize(*args) super validate_identifier(@args[1]) end |
Class Method Details
.max_param_count ⇒ Object
11 12 13 |
# File 'lib/dentaku/ast/functions/enum.rb', line 11 def self.max_param_count 3 end |
.min_param_count ⇒ Object
7 8 9 |
# File 'lib/dentaku/ast/functions/enum.rb', line 7 def self.min_param_count 3 end |
Instance Method Details
#dependencies(context = {}) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/dentaku/ast/functions/enum.rb', line 20 def dependencies(context = {}) collection = @args[0] item_identifier = @args[1].identifier expression = @args[2] collection_deps = collection.dependencies(context) expression_deps = (expression&.dependencies(context) || []).reject do |i| i == item_identifier || i.start_with?("#{item_identifier}.") end collection_deps + expression_deps end |
#validate_identifier(arg, message = "#{name}() requires second argument to be an identifier") ⇒ Object
33 34 35 |
# File 'lib/dentaku/ast/functions/enum.rb', line 33 def validate_identifier(arg, = "#{name}() requires second argument to be an identifier") raise ParseError.for(:node_invalid), unless arg.is_a?(Identifier) end |