Class: Quantumdmn::DmnEngine
- Inherits:
-
Object
- Object
- Quantumdmn::DmnEngine
- Defined in:
- lib/quantumdmn/dmn_engine.rb
Overview
high-level wrapper for DMN engine evaluation simplifies interaction with the API by providing a clean evaluate method
Instance Attribute Summary collapse
-
#api ⇒ Object
readonly
Returns the value of attribute api.
-
#project_id ⇒ Object
readonly
Returns the value of attribute project_id.
Instance Method Summary collapse
-
#evaluate(definition_id, context, version: nil) ⇒ Hash
evaluate a DMN definition automatically detects whether definition_id is a UUID or XML ID.
-
#initialize(api_client, project_id) ⇒ DmnEngine
constructor
initialize the DMN engine client.
Constructor Details
#initialize(api_client, project_id) ⇒ DmnEngine
initialize the DMN engine client
12 13 14 15 |
# File 'lib/quantumdmn/dmn_engine.rb', line 12 def initialize(api_client, project_id) @api = DefaultApi.new(api_client) @project_id = project_id end |
Instance Attribute Details
#api ⇒ Object (readonly)
Returns the value of attribute api.
7 8 9 |
# File 'lib/quantumdmn/dmn_engine.rb', line 7 def api @api end |
#project_id ⇒ Object (readonly)
Returns the value of attribute project_id.
7 8 9 |
# File 'lib/quantumdmn/dmn_engine.rb', line 7 def project_id @project_id end |
Instance Method Details
#evaluate(definition_id, context, version: nil) ⇒ Hash
evaluate a DMN definition automatically detects whether definition_id is a UUID or XML ID
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/quantumdmn/dmn_engine.rb', line 23 def evaluate(definition_id, context, version: nil) # prepare request body (don't include version in request - it goes in opts) request_body = EvaluateStoredRequest.new(context: context) # detect if definition_id is a UUID (36 chars with dashes) or XML ID if uuid?(definition_id) # use UUID endpoint @api.evaluate_stored(@project_id, definition_id, request_body) else # use XML ID endpoint - version goes in opts hash opts = version ? { version: version } : {} @api.evaluate_by_xmlid(@project_id, definition_id, request_body, opts) end end |