Class: Api::Partner::TicketGroupFilter
- Inherits:
-
Object
- Object
- Api::Partner::TicketGroupFilter
- Defined in:
- app/filters/api/partner/ticket_group_filter.rb
Overview
Responsible to filter reservations data dashboard
Instance Attribute Summary collapse
-
#collections ⇒ Object
Returns the value of attribute collections.
-
#error_message ⇒ Object
Returns the value of attribute error_message.
Instance Method Summary collapse
-
#build_collections ⇒ Object
get desired reservations from database.
- #filter(filter_par) ⇒ Object
-
#initialize(collections = nil) ⇒ TicketGroupFilter
constructor
A new instance of TicketGroupFilter.
- #order_by(order) ⇒ Object
- #to_collections ⇒ Object
Constructor Details
#initialize(collections = nil) ⇒ TicketGroupFilter
Returns a new instance of TicketGroupFilter.
9 10 11 12 |
# File 'app/filters/api/partner/ticket_group_filter.rb', line 9 def initialize(collections = nil) self.collections = collections unless collections.nil? @config = {} end |
Instance Attribute Details
#collections ⇒ Object
Returns the value of attribute collections.
6 7 8 |
# File 'app/filters/api/partner/ticket_group_filter.rb', line 6 def collections @collections end |
#error_message ⇒ Object
Returns the value of attribute error_message.
6 7 8 |
# File 'app/filters/api/partner/ticket_group_filter.rb', line 6 def @error_message end |
Instance Method Details
#build_collections ⇒ Object
get desired reservations from database
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/filters/api/partner/ticket_group_filter.rb', line 24 def build_collections if filter_params _filter_by_voucher_id _filter_by_voucher_name _filter_by_voucher_price _filter_by_quantity _filter_by_package_type _filter_by_selling_date_range _filter_by_valid_date_range _filter_by_selling_date _filter_by_valid_date end _order_by collections.group(:id) end |
#filter(filter_par) ⇒ Object
15 16 17 18 |
# File 'app/filters/api/partner/ticket_group_filter.rb', line 15 def filter(filter_par) return unless filter_par.present? config[:filter] = filter_par end |
#order_by(order) ⇒ Object
20 21 22 |
# File 'app/filters/api/partner/ticket_group_filter.rb', line 20 def order_by(order) config[:order_by] = order end |
#to_collections ⇒ Object
40 41 42 |
# File 'app/filters/api/partner/ticket_group_filter.rb', line 40 def to_collections build_collections.order(created_at: :desc) end |