Class: Jazari::RecipeRecord
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Jazari::RecipeRecord
- Defined in:
- app/models/jazari/recipe_record.rb
Overview
The persisted canon. Deliberately named RecipeRecord, not Recipe: Recipe
is the immutable value the domain passes around, and letting an ActiveRecord
object wear that name is how unsaved records leak into return values.
Constant Summary collapse
Class Method Summary collapse
-
.table_name ⇒ Object
Resolved on EVERY call, not assigned at class-definition time.
Instance Method Summary collapse
Class Method Details
.table_name ⇒ Object
Resolved on EVERY call, not assigned at class-definition time.
Assigning it eagerly made the binding depend on load order: under Zeitwerk
a host's configure runs before these constants autoload, so the
assignment never happened and the model silently kept the gem's default
name. A host adopting existing tables then queried tables that do not
exist. Reading config here removes the ordering question entirely.
15 |
# File 'app/models/jazari/recipe_record.rb', line 15 def self.table_name = Jazari.table_name_for(:recipes) |
Instance Method Details
#to_recipe ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'app/models/jazari/recipe_record.rb', line 25 def to_recipe Recipe.new( id: recipe_id, version: version, topic: topic, description: description, run_policy: run_policy, checklist: Array(checklist).map do |item| { id: item["id"].to_s, text: item["text"].to_s, done: item["done"] == true, required: item.fetch("required", true) == true } end ) end |