Pull shipping method service computations out of the serialization loop

This commit is contained in:
Rohan Mitchell
2015-05-21 12:40:04 +10:00
parent f0e909c92b
commit ee8db23fd9
2 changed files with 5 additions and 3 deletions

View File

@@ -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