Class: Api::Partner::BaseSerializer
- Inherits:
-
Object
- Object
- Api::Partner::BaseSerializer
- Includes:
- JSONAPI::Serializer
- Defined in:
- app/serializers/api/partner/base_serializer.rb
Direct Known Subclasses
AttachmentSerializer, ChannelSerializer, CitySerializer, DistrictSerializer, FaqSerializer, InventorySerializer, MenuSectionSerializer, PackageMenuSerializer, PackageSerializer, PictureSerializer, ReservationSerializer, ReservationSummarySerializer, RestaurantAddOnSerializer, RestaurantDocumentSerializer, RestaurantPackageSerializer, RestaurantSerializer, RestaurantTagSerializer, ReviewSerializer, StaffSerializer, TicketGroupSerializer, TicketSerializer, TransactionNotifSerializer, UpdatedInventorySerializer
Class Method Summary collapse
- .enable_caching ⇒ Object
- .mtime ⇒ Object
-
.record_cache_options(options, fieldset, include_list, params) ⇒ Object
The method appends locale and an optional custom cache key to the cache namespace to differentiate cached data based on locale and any updates to associated data.
Class Method Details
.enable_caching ⇒ Object
10 11 12 |
# File 'app/serializers/api/partner/base_serializer.rb', line 10 def self.enable_caching store: Rails.cache, namespace: 'api/partner', expires_in: 12.hours, enabled: true end |
.mtime ⇒ Object
6 7 8 |
# File 'app/serializers/api/partner/base_serializer.rb', line 6 def self.mtime File.mtime Rails.root.join('app', 'serializers', "#{to_s.underscore}.rb").to_s end |
.record_cache_options(options, fieldset, include_list, params) ⇒ Object
The method appends locale and an optional custom cache key to the cache namespace to differentiate cached data based on locale and any updates to associated data.
Example Usage: cache_key = “staff_profile:#Api::Partner::BaseSerializer.restaurantsrestaurants.cache_key” Api::Partner::StaffSerializer.new(current_staff, params: { cache_key: cache_key })
20 21 22 23 24 25 |
# File 'app/serializers/api/partner/base_serializer.rb', line 20 def self.(, fieldset, include_list, params) opts = .dup opts[:namespace] += ":#{MyLocaleManager.normalize_locale}" opts[:namespace] += ":#{params[:cache_key]}" if params[:cache_key].present? super(opts, fieldset, include_list, params) end |