1
0

Renamed: column -> exposure

Moved toggle_column_options to body_trackers helper
This commit is contained in:
cryptogopher
2020-04-25 15:42:22 +02:00
parent 5e3322fe96
commit a4781b4fcd
18 changed files with 57 additions and 55 deletions

View File

@@ -13,7 +13,7 @@ module BodyTracking::ProjectPatch
has_many :units, dependent: :destroy
has_many :nutrient_exposures, as: :view, dependent: :destroy,
class_name: 'Exposure', extend: BodyTracking::TogglableColumns
class_name: 'Exposure', extend: BodyTracking::TogglableExposures
has_many :nutrient_quantities, -> { order "lft" }, through: :nutrient_exposures,
source: 'quantity'
end

View File

@@ -1,7 +0,0 @@
module BodyTracking::TogglableColumns
# TODO: enforce 'domain' identity between quantites and receiving collection?
def toggle!(q)
column = find_by(quantity: q)
column ? destroy(column) : create(quantity: q)
end
end

View File

@@ -0,0 +1,7 @@
module BodyTracking::TogglableExposures
# TODO: enforce 'domain' identity between quantites and receiving collection?
def toggle!(q)
exposure = find_by(quantity: q)
exposure ? destroy(exposure) : create(quantity: q)
end
end