:thinking_face: Weird class var mutation issues ... ?
parent
60b85e4d38
commit
903e3ce1b5
|
@ -4,8 +4,6 @@ module Resources
|
|||
DESTROY = "destroy"
|
||||
]
|
||||
RESOURCES = { # Because I don't trust Kernel.const_get
|
||||
# "DeviceConfig" => DeviceConfig,
|
||||
# "DiagnosticDump" => DiagnosticDump,
|
||||
"FarmEvent" => FarmEvent,
|
||||
"FarmwareInstallations" => FarmwareInstallations,
|
||||
"Image" => Image,
|
||||
|
|
|
@ -19,8 +19,6 @@ module Resources
|
|||
when DESTROY then do_deletion
|
||||
else; never
|
||||
end
|
||||
rescue => x
|
||||
binding.pry
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -33,6 +31,8 @@ module Resources
|
|||
model_name = resource.model_name
|
||||
mutation = Kernel.const_get(model_name.name.pluralize)::Destroy
|
||||
mutation.run!(model_name.singular => model, device: device)
|
||||
rescue => x
|
||||
binding.pry
|
||||
end
|
||||
|
||||
def model
|
||||
|
|
|
@ -10,6 +10,7 @@ class CreateDestroyer < Mutations::Command
|
|||
end
|
||||
|
||||
def execute
|
||||
# MAGIC AHEAD: Pull stuff into scope for block below.
|
||||
symbolized_name = resource.model_name.singular
|
||||
klass = resource
|
||||
|
||||
|
@ -27,6 +28,8 @@ class CreateDestroyer < Mutations::Command
|
|||
|
||||
def execute
|
||||
self.send(@@resource_name).destroy! && ""
|
||||
rescue => x
|
||||
binding.pry
|
||||
end
|
||||
|
||||
def not_yours
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
module DiagnosticDumps
|
||||
Destroy = CreateDestroyer.run!(resource: DiagnosticDump)
|
||||
end
|
|
@ -0,0 +1,3 @@
|
|||
module FarmEvents
|
||||
Destroy = CreateDestroyer.run!(resource: FarmEvent)
|
||||
end
|
|
@ -0,0 +1,3 @@
|
|||
module FarmwareInstallations
|
||||
Destroy = CreateDestroyer.run!(resource: FarmwareInstallation)
|
||||
end
|
|
@ -0,0 +1,3 @@
|
|||
module Images
|
||||
Destroy = CreateDestroyer.run!(resource: Image)
|
||||
end
|
|
@ -0,0 +1,3 @@
|
|||
module Logs
|
||||
Destroy = CreateDestroyer.run!(resource: Log)
|
||||
end
|
|
@ -0,0 +1,3 @@
|
|||
module PlantTemplates
|
||||
Destroy = CreateDestroyer.run!(resource: PlantTemplate)
|
||||
end
|
|
@ -4,8 +4,6 @@ Not all resources support the experimental resource API.
|
|||
|
||||
|Resource |Delete? |Upsert? |
|
||||
|-----------------------|---------|---------|
|
||||
| DeviceConfig |No |No |
|
||||
| DiagnosticDump |No |No |
|
||||
| FarmEvent |No |No |
|
||||
| FarmwareInstallations |No |No |
|
||||
| Image |No |No |
|
||||
|
|
|
@ -8,22 +8,20 @@ describe Resources::Job do
|
|||
{ body: {}, device: device, action: "destroy", uuid: SecureRandom.uuid }
|
||||
|
||||
test_cases = [
|
||||
# DeviceConfig,
|
||||
# DiagnosticDump,
|
||||
# FarmEvent,
|
||||
# FarmwareInstallation,
|
||||
# Image,
|
||||
# Log,
|
||||
# PlantTemplate,
|
||||
# Point,
|
||||
# Regimen,
|
||||
# SavedGarden,
|
||||
# SensorReading,
|
||||
FarmEvent,
|
||||
FarmwareInstallation,
|
||||
Image,
|
||||
Log,
|
||||
PlantTemplate,
|
||||
SavedGarden,
|
||||
SensorReading,
|
||||
WebcamFeed,
|
||||
Peripheral,
|
||||
PinBinding,
|
||||
Sensor,
|
||||
Tool,
|
||||
# Tool,
|
||||
# Point,
|
||||
# Regimen,
|
||||
]
|
||||
.each{ |k| k.destroy_all }
|
||||
.map { |k| FactoryBot.create(k.model_name.singular.to_sym, device: device) }
|
||||
|
|
Loading…
Reference in New Issue