Class: ActsAsCalculator::FormulaVersionsController
- Inherits:
-
ApplicationController
- Object
- ActionController::API
- ApplicationController
- ActsAsCalculator::FormulaVersionsController
- Defined in:
- app/controllers/acts_as_calculator/formula_versions_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
Straight through
PublishFormulaVersion, so the API takes exactly the same route through the effective-dating rules as the JSON import does: the incumbent is superseded, never rewritten, and a supersede that would leave part of its range with no active version raisesPartialSupersedeError— surfaced as a 409, not swallowed. - #index ⇒ Object
- #show ⇒ Object
Instance Method Details
#create ⇒ Object
Straight through PublishFormulaVersion, so the API takes exactly the same route
through the effective-dating rules as the JSON import does: the incumbent is
superseded, never rewritten, and a supersede that would leave part of its range with
no active version raises PartialSupersedeError — surfaced as a 409, not swallowed.
19 20 21 22 23 24 |
# File 'app/controllers/acts_as_calculator/formula_versions_controller.rb', line 19 def create published = PublishFormulaVersion.(formula:, **version_attributes) render json: { version: SerializeFormulaVersion.(version: published, variables: true) }, status: :created end |
#index ⇒ Object
5 6 7 8 9 |
# File 'app/controllers/acts_as_calculator/formula_versions_controller.rb', line 5 def index versions = formula.versions.order(:version_number) render json: { versions: versions.map { |version| SerializeFormulaVersion.(version:) } } end |
#show ⇒ Object
11 12 13 |
# File 'app/controllers/acts_as_calculator/formula_versions_controller.rb', line 11 def show render json: { version: SerializeFormulaVersion.(version:, variables: true) } end |