Class: ActsAsCalculator::FormulasController
- Inherits:
-
ApplicationController
- Object
- ActionController::API
- ApplicationController
- ActsAsCalculator::FormulasController
- Defined in:
- app/controllers/acts_as_calculator/formulas_controller.rb
Overview
Identity only — key, scope, owner. Everything that can change about a formula is
a version, which is why there is a separate controller for those.
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
15 16 17 18 19 |
# File 'app/controllers/acts_as_calculator/formulas_controller.rb', line 15 def create created = Formula.create!(**formula_attributes) render json: { formula: SerializeFormula.(formula: created) }, status: :created end |
#destroy ⇒ Object
27 28 29 30 31 |
# File 'app/controllers/acts_as_calculator/formulas_controller.rb', line 27 def destroy formula.destroy! head :no_content end |
#index ⇒ Object
7 8 9 |
# File 'app/controllers/acts_as_calculator/formulas_controller.rb', line 7 def index render json: { formulas: scoped_formulas.map { |formula| SerializeFormula.(formula:) } } end |
#show ⇒ Object
11 12 13 |
# File 'app/controllers/acts_as_calculator/formulas_controller.rb', line 11 def show render json: { formula: SerializeFormula.(formula:, versions: true) } end |
#update ⇒ Object
21 22 23 24 25 |
# File 'app/controllers/acts_as_calculator/formulas_controller.rb', line 21 def update formula.update!(**formula_attributes) render json: { formula: SerializeFormula.(formula:) } end |