Renamed: column -> exposure
Moved toggle_column_options to body_trackers helper
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
7
lib/body_tracking/togglable_exposures.rb
Normal file
7
lib/body_tracking/togglable_exposures.rb
Normal 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
|
||||
Reference in New Issue
Block a user