Class: AhoyCaptain::FilterParser
- Inherits:
-
Object
- Object
- AhoyCaptain::FilterParser
- Defined in:
- app/models/ahoy_captain/filter_parser.rb
Defined Under Namespace
Classes: Item
Constant Summary collapse
- FILTER_MENU_MAX_SIZE =
2
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(request) ⇒ FilterParser
constructor
A new instance of FilterParser.
- #parse ⇒ Object
Constructor Details
#initialize(request) ⇒ FilterParser
Returns a new instance of FilterParser.
20 21 22 23 24 25 |
# File 'app/models/ahoy_captain/filter_parser.rb', line 20 def initialize(request) @request = request @params = @request.params @filter_params = @request.params[:q] || {} @items = {} end |
Class Method Details
.parse(request) ⇒ Object
12 13 14 15 16 |
# File 'app/models/ahoy_captain/filter_parser.rb', line 12 def self.parse(request) new(request).tap do |instance| instance.parse end end |
Instance Method Details
#parse ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'app/models/ahoy_captain/filter_parser.rb', line 27 def parse @filter_params.each do |key, values| next if ::AhoyCaptain.event.ransackable_scopes.include?(key.to_sym) item = build_item(key, values) @items[key] = item end @items end |