Module: Card::Set::Abstract::FilterHelper::Format

Extended by:
Card::Set::AbstractFormat
Defined in:
card/tmpsets/set/mod035-card-mod-search/abstract/00_filter_helper.rb,
card/tmpsets/set/mod036-card-mod-search/abstract/00_filter_helper.rb

Instance Method Summary collapse

Instance Method Details

#default_filter_hashObject

initial values for filtered search



40
41
42
# File 'card/tmpsets/set/mod035-card-mod-search/abstract/00_filter_helper.rb', line 40

def default_filter_hash
  {}
end

#extra_paging_path_argsObject



44
45
46
# File 'card/tmpsets/set/mod035-card-mod-search/abstract/00_filter_helper.rb', line 44

def extra_paging_path_args
  super.merge filter_and_sort_hash
end

#filter_and_sort_hashObject



48
49
50
51
52
# File 'card/tmpsets/set/mod035-card-mod-search/abstract/00_filter_helper.rb', line 48

def filter_and_sort_hash
  { filter: filter_hash }.tap do |hash|
    hash[:sort] = sort_param if sort_param
  end
end

#filter_hashObject



13
14
15
# File 'card/tmpsets/set/mod035-card-mod-search/abstract/00_filter_helper.rb', line 13

def filter_hash
  @filter_hash ||= filter_hash_from_params || default_filter_hash
end

#filter_hash_from_paramsObject



17
18
19
20
21
# File 'card/tmpsets/set/mod035-card-mod-search/abstract/00_filter_helper.rb', line 17

def filter_hash_from_params
  return unless Env.params[:filter].present?

  Env.hash(Env.params[:filter]).deep_symbolize_keys
end

#filter_keys_with_valuesObject



32
33
34
35
36
37
# File 'card/tmpsets/set/mod035-card-mod-search/abstract/00_filter_helper.rb', line 32

def filter_keys_with_values
  filter_keys.map do |key|
    values = filter_param(key)
    values.present? ? [key, values] : next
  end.compact
end

#filter_param(field) ⇒ Object



9
10
11
# File 'card/tmpsets/set/mod035-card-mod-search/abstract/00_filter_helper.rb', line 9

def filter_param field
  filter_hash[field.to_sym]
end

#safe_sql_param(key) ⇒ Object



27
28
29
30
# File 'card/tmpsets/set/mod035-card-mod-search/abstract/00_filter_helper.rb', line 27

def safe_sql_param key
  param = Env.params[key]
  param.blank? ? nil : Card::Query.safe_sql(param)
end

#sort_paramObject



23
24
25
# File 'card/tmpsets/set/mod035-card-mod-search/abstract/00_filter_helper.rb', line 23

def sort_param
  @sort_param ||= safe_sql_param :sort
end