Class: Api::Vendor::V1::ReservationsFilter
- Inherits:
-
Object
- Object
- Api::Vendor::V1::ReservationsFilter
- Defined in:
- app/filters/api/vendor/v1/reservations_filter.rb
Overview
Responsible to filter reservations data based on user ID
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
- #active_only(val) ⇒ Object
-
#build_collections ⇒ Object
get desired reservations from database.
- #dining_time(time_x, operator, time_y = nil) ⇒ Object
- #end_date(date) ⇒ Object
- #exclude_no_package ⇒ Object
- #init_default(vendor, user) ⇒ Object
-
#initialize(collections = nil) ⇒ ReservationsFilter
constructor
A new instance of ReservationsFilter.
- #need_review(val) ⇒ Object
- #not_pending(val) ⇒ Object
- #order_by(order) ⇒ Object
- #page_number(number) ⇒ Object
- #pending(val) ⇒ Object
- #per_page(number) ⇒ Object
- #start_date(date) ⇒ Object
Constructor Details
#initialize(collections = nil) ⇒ ReservationsFilter
Returns a new instance of ReservationsFilter.
11 12 13 14 |
# File 'app/filters/api/vendor/v1/reservations_filter.rb', line 11 def initialize(collections = nil) self.collections = collections unless collections.nil? @config = {} end |
Instance Attribute Details
#collections ⇒ Object
Returns the value of attribute collections.
8 9 10 |
# File 'app/filters/api/vendor/v1/reservations_filter.rb', line 8 def collections @collections end |
#error_message ⇒ Object
Returns the value of attribute error_message.
8 9 10 |
# File 'app/filters/api/vendor/v1/reservations_filter.rb', line 8 def @error_message end |
Instance Method Details
#active_only(val) ⇒ Object
36 37 38 39 |
# File 'app/filters/api/vendor/v1/reservations_filter.rb', line 36 def active_only(val) config[:active_only] = val self end |
#build_collections ⇒ Object
get desired reservations from database
96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'app/filters/api/vendor/v1/reservations_filter.rb', line 96 def build_collections _init_default _need_review _filter_no_package _active_only _not_pending _pending _exclude_no_package _filter_by_dining_time _order_by _paginate _filter_by_date collections end |
#dining_time(time_x, operator, time_y = nil) ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'app/filters/api/vendor/v1/reservations_filter.rb', line 63 def dining_time(time_x, operator, time_y = nil) config[:dining_time] = { time_x: time_x, operator: operator, time_y: time_y, } self end |
#end_date(date) ⇒ Object
76 77 78 |
# File 'app/filters/api/vendor/v1/reservations_filter.rb', line 76 def end_date(date) config[:end_date] = date end |
#exclude_no_package ⇒ Object
90 91 92 93 |
# File 'app/filters/api/vendor/v1/reservations_filter.rb', line 90 def exclude_no_package config[:exclude_no_package] = true self end |
#init_default(vendor, user) ⇒ Object
17 18 19 20 21 22 |
# File 'app/filters/api/vendor/v1/reservations_filter.rb', line 17 def init_default(vendor, user) config[:vendor] = vendor config[:user] = user self end |
#need_review(val) ⇒ Object
51 52 53 54 |
# File 'app/filters/api/vendor/v1/reservations_filter.rb', line 51 def need_review(val) config[:need_review] = val self end |
#not_pending(val) ⇒ Object
41 42 43 44 |
# File 'app/filters/api/vendor/v1/reservations_filter.rb', line 41 def not_pending(val) config[:not_pending] = val self end |
#order_by(order) ⇒ Object
29 30 31 32 33 34 |
# File 'app/filters/api/vendor/v1/reservations_filter.rb', line 29 def order_by(order) return self if order.blank? config[:order_by] = order self end |
#page_number(number) ⇒ Object
80 81 82 83 |
# File 'app/filters/api/vendor/v1/reservations_filter.rb', line 80 def page_number(number) config[:page_number] = number.to_i if number.to_i.positive? self end |
#pending(val) ⇒ Object
46 47 48 49 |
# File 'app/filters/api/vendor/v1/reservations_filter.rb', line 46 def pending(val) config[:pending] = val self end |
#per_page(number) ⇒ Object
85 86 87 88 |
# File 'app/filters/api/vendor/v1/reservations_filter.rb', line 85 def per_page(number) config[:per_page] = number.to_i if number.to_i.positive? self end |
#start_date(date) ⇒ Object
72 73 74 |
# File 'app/filters/api/vendor/v1/reservations_filter.rb', line 72 def start_date(date) config[:start_date] = date end |