Class: ActsAsCalculatorEditor::ValidationsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/acts_as_calculator_editor/validations_controller.rb

Overview

The engine's only JSON endpoint, and the exception that proves the rule in docs/core-gem-contract.md §1: this is a live-typing helper for the expression field, not a CRUD surface. It reads nothing but lookup-table existence and writes nothing at all.

Debounce it from the client. It parses an expression and runs at most one indexed lookup per declared lookup variable, so it is cheap — but it is still a request per keystroke if nobody says otherwise.

Instance Method Summary collapse

Instance Method Details

#createObject



16
17
18
19
20
21
# File 'app/controllers/acts_as_calculator_editor/validations_controller.rb', line 16

def create
  render json: ValidateExpression.(expression: params[:expression],
                                   variables: CastVariableRows.(params[:variables]),
                                   scope: params[:scope],
                                   owner: current_owner)
end