Class: AhoyCaptain::FilterParser

Inherits:
Object
  • Object
show all
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

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

#parseObject



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