The list of platforms lived on `PlatformLink::SUPPORTED_PLATFORMS` — a model
about links to a platform's website — and was copied around it four times in
the admin (`%w[tic80 ebitengine love c64 godot bevy phaser]`), spelled out in
three apipie descriptions, and turned into a class name by string
interpolation in three services:
"WarpEngine::Platforms::#{platform.camelize}::Service".constantize
Seven places that had to agree, and nothing that made them.
`WarpEngine::Platform` is now that one place. `Platform.names` is the list,
`Platform.find!("godot")` answers with a value object that knows its `label`,
its `expected_kinds` and its updater `service`, and the constantize is gone —
the registry holds the reference. `PublishService` and `BuildsService` ask it,
the admin selects read `Platform.names`, and
`PlatformLink::SUPPORTED_PLATFORMS` stays as an alias of `Platform::NAMES` so
a host pinned to 0.7 keeps working.
`Software` also defends its own value sets now. It validated neither `status`
nor `platform`, so a mistyped platform only surfaced later, at publish time,
as "Unsupported platform" — after the row existed. And `status` had three
different answers depending on where you looked: the admin offered
development/demo/released/archived, the API documentation claimed
"active, inactive", and the database holds the first four. `Software::STATUSES`
is the list, the inclusion validations enforce both, and the documentation
names the values the database actually has.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
53 lines
1.4 KiB
Ruby
53 lines
1.4 KiB
Ruby
ActiveAdmin.register WarpEngine::PlatformLink, as: "Platform Link" do
|
|
permit_params :name, :url, :platform, :position
|
|
|
|
menu parent: "🌀 WarpEngine", priority: 5, label: "🔗 Platform Links"
|
|
|
|
config.sort_order = "platform_asc"
|
|
|
|
scope :all, default: true
|
|
scope("TIC-80") { |s| s.where(platform: "tic80") }
|
|
scope("Ebitengine") { |s| s.where(platform: "ebitengine") }
|
|
scope("LOVE") { |s| s.where(platform: "love") }
|
|
scope("C64") { |s| s.where(platform: "c64") }
|
|
scope("Godot") { |s| s.where(platform: "godot") }
|
|
scope("Bevy") { |s| s.where(platform: "bevy") }
|
|
scope("Phaser") { |s| s.where(platform: "phaser") }
|
|
|
|
index do
|
|
selectable_column
|
|
id_column
|
|
column :platform
|
|
column :name
|
|
column(:url) { |pl| link_to pl.url, pl.url, target: "_blank" }
|
|
column :position
|
|
column :created_at
|
|
actions
|
|
end
|
|
|
|
filter :platform, as: :select, collection: WarpEngine::Platform.names
|
|
filter :name
|
|
|
|
form do |f|
|
|
f.inputs do
|
|
f.input :platform, as: :select, collection: WarpEngine::Platform.names
|
|
f.input :name
|
|
f.input :url
|
|
f.input :position, as: :number, input_html: { min: 0 }
|
|
end
|
|
f.actions
|
|
end
|
|
|
|
show do
|
|
attributes_table do
|
|
row :id
|
|
row :platform
|
|
row :name
|
|
row(:url) { |pl| link_to pl.url, pl.url, target: "_blank" }
|
|
row :position
|
|
row :created_at
|
|
row :updated_at
|
|
end
|
|
end
|
|
end
|