Class: DecisionAgent::Dmn::Feel::Functions::Base
- Inherits:
-
Object
- Object
- DecisionAgent::Dmn::Feel::Functions::Base
- Defined in:
- lib/decision_agent/dmn/feel/functions.rb
Overview
Base class for all functions
Direct Known Subclasses
Abs, All, Any, Append, Ceiling, Contains, Count, DateFunction, DistinctValues, DurationFunction, EndsWith, Even, Floor, IndexOf, LowerCase, Max, Mean, Min, Modulo, Not, Odd, Replace, Reverse, Round, Sqrt, StartsWith, StringLength, Substring, SubstringAfter, SubstringBefore, Sum, TimeFunction, UpperCase
Class Method Summary collapse
-
.call(args, context = {}) ⇒ Object
Execute function with arguments and context Returns either a value or a ConditionEvaluator condition structure.
-
.register(*names) ⇒ Object
Register function with one or more names.
-
.validate_arg_count(args, expected) ⇒ Object
Validate argument count.
Class Method Details
.call(args, context = {}) ⇒ Object
Execute function with arguments and context Returns either a value or a ConditionEvaluator condition structure
27 28 29 |
# File 'lib/decision_agent/dmn/feel/functions.rb', line 27 def call(args, context = {}) raise NotImplementedError, "Subclasses must implement call" end |
.register(*names) ⇒ Object
Register function with one or more names
21 22 23 |
# File 'lib/decision_agent/dmn/feel/functions.rb', line 21 def register(*names) names.each { |name| REGISTRY[name.to_s] = self } end |
.validate_arg_count(args, expected) ⇒ Object
Validate argument count
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/decision_agent/dmn/feel/functions.rb', line 32 def validate_arg_count(args, expected) actual = args.length valid = if expected.is_a?(Range) expected.cover?(actual) else actual == expected end return if valid raise FeelFunctionError, "Wrong number of arguments for #{name} (got #{actual}, expected #{expected})" end |