mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-26 05:55:15 +00:00
Pull shipping method service computations out of the serialization loop
This commit is contained in:
@@ -42,11 +42,13 @@ class Api::CachedEnterpriseSerializer < ActiveModel::Serializer
|
||||
has_one :address, serializer: Api::AddressSerializer
|
||||
|
||||
def pickup
|
||||
object.shipping_methods.where(:require_ship_address => false).present?
|
||||
services = options[:shipping_method_services][object.id]
|
||||
services ? services[:pickup] : false
|
||||
end
|
||||
|
||||
def delivery
|
||||
object.shipping_methods.where(:require_ship_address => true).present?
|
||||
services = options[:shipping_method_services][object.id]
|
||||
services ? services[:delivery] : false
|
||||
end
|
||||
|
||||
def email
|
||||
|
||||
Reference in New Issue
Block a user