Class: Api::Partner::RestaurantAddOnsFilter

Inherits:
Object
  • Object
show all
Includes:
ElasticAPM::SpanHelpers
Defined in:
app/filters/api/partner/restaurant_add_ons_filter.rb

Overview

Responsible to filter restaurant add-ons data

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(add_ons) ⇒ RestaurantAddOnsFilter

Returns a new instance of RestaurantAddOnsFilter.



9
10
11
12
13
14
15
16
17
18
# File 'app/filters/api/partner/restaurant_add_ons_filter.rb', line 9

def initialize(add_ons)
  @add_ons = add_ons
  self.collections = default_collections
  @time_zone = if @add_ons.present?
                 Time.now.in_time_zone(@add_ons.first.restaurant.time_zone).utc_offset / 3600
               else
                 0 # Default to UTC if no add_ons present
               end
  @config = {}
end

Instance Attribute Details

#collectionsObject

Returns the value of attribute collections.



7
8
9
# File 'app/filters/api/partner/restaurant_add_ons_filter.rb', line 7

def collections
  @collections
end

#error_messageObject

Returns the value of attribute error_message.



7
8
9
# File 'app/filters/api/partner/restaurant_add_ons_filter.rb', line 7

def error_message
  @error_message
end

#time_zoneObject

Returns the value of attribute time_zone.



7
8
9
# File 'app/filters/api/partner/restaurant_add_ons_filter.rb', line 7

def time_zone
  @time_zone
end

Instance Method Details

#build_collectionsObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/filters/api/partner/restaurant_add_ons_filter.rb', line 30

def build_collections
  if filter_params
    _filter_by_add_on_id
    _filter_by_name
    _filter_by_status
    _filter_by_price_type
    _filter_by_created_date_range
    _filter_by_updated_date_range
    _filter_by_created_date
    _filter_by_updated_date
  end
  _order_by
  collections
end

#filter(filter_par) ⇒ Object



20
21
22
23
24
# File 'app/filters/api/partner/restaurant_add_ons_filter.rb', line 20

def filter(filter_par)
  return if filter_par.blank?

  config[:filter] = filter_par
end

#order_by(order) ⇒ Object



26
27
28
# File 'app/filters/api/partner/restaurant_add_ons_filter.rb', line 26

def order_by(order)
  config[:order_by] = order
end