Class: AdaptivePointsSerializer

Inherits:
ApplicationSerializer show all
Defined in:
app/serializers/adaptive_points_serializer.rb

Overview

typed: ignore frozen_string_literal: true

Instance Method Summary collapse

Methods inherited from ApplicationSerializer

decorate_attributes, decorator, #object_cache_key

Instance Method Details

#created_atObject



15
16
17
# File 'app/serializers/adaptive_points_serializer.rb', line 15

def created_at
  "#{object&.created_at&.strftime('%Y-%m-%d')}"
end

#end_dateObject



11
12
13
# File 'app/serializers/adaptive_points_serializer.rb', line 11

def end_date
  "#{object&.end_date&.strftime('%Y-%m-%d')}" || '' 
end

#resto_group_tagObject



19
20
21
22
23
24
25
26
27
# File 'app/serializers/adaptive_points_serializer.rb', line 19

def resto_group_tag
  if object.campaign_type == 'Restaurant'
    object.campaign.name
  elsif object.campaign_type == 'RestaurantGroup'  
    object.campaign.name
  elsif object.campaign_type == 'RestaurantTag'
    object.campaign.title
  end
end

#start_dateObject



7
8
9
# File 'app/serializers/adaptive_points_serializer.rb', line 7

def start_date
  "#{object.start_date.strftime('%Y-%m-%d')}"
end