Class: Api::Dashboard::UpdatedInventoryFilter
- Inherits:
-
Object
- Object
- Api::Dashboard::UpdatedInventoryFilter
- Defined in:
- app/filters/api/dashboard/updated_inventory_filter.rb
Overview
Responsible to filter updated inventories 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) ⇒ UpdatedInventoryFilter
constructor
A new instance of UpdatedInventoryFilter.
- #to_collections ⇒ Object
Constructor Details
#initialize(collections = nil) ⇒ UpdatedInventoryFilter
Returns a new instance of UpdatedInventoryFilter.
8 9 10 11 |
# File 'app/filters/api/dashboard/updated_inventory_filter.rb', line 8 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/dashboard/updated_inventory_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/dashboard/updated_inventory_filter.rb', line 6 def @error_message end |
Instance Method Details
#build_collections ⇒ Object
get desired reservations from database
20 21 22 23 24 25 26 27 28 29 |
# File 'app/filters/api/dashboard/updated_inventory_filter.rb', line 20 def build_collections if filter_params _filter_by_start_date _filter_by_end_date _filter_by_start_time _filter_by_end_time _filter_by_date_range end collections end |
#filter(filter_par) ⇒ Object
14 15 16 17 |
# File 'app/filters/api/dashboard/updated_inventory_filter.rb', line 14 def filter(filter_par) return unless filter_par.present? config[:filter] = filter_par end |
#to_collections ⇒ Object
31 32 33 |
# File 'app/filters/api/dashboard/updated_inventory_filter.rb', line 31 def to_collections build_collections.order(created_at: :desc) end |