Module: Card::Set::Abstract::Filter

Extended by:
Card::Set
Defined in:
tmpsets/set/mod020-search/abstract/03_filter.rb

Overview

Set: Abstract (Filter)

Defined Under Namespace

Modules: HtmlFormat

Class Method Summary collapse

Instance Method Summary collapse

Methods included from I18nScope

#mod_name, #scope

Methods included from Loader

#clean_empty_module_from_hash, #clean_empty_modules, #extended, #process_base_modules, #register_set

Methods included from Helpers

#abstract_set?, #all_set?, #num_set_parts, #shortname, #underscore

Methods included from Card::Set::AdvancedApi

#attachment, #ensure_set, #stage_method

Methods included from Format

#before, #format, layout_method_name, #view, view_method_name, view_setting_method_name, wrapper_method_name

Methods included from Inheritance

#include_set, #include_set_formats

Methods included from Basket

#abstract_basket, #add_to_basket, #basket, #unshift_basket

Methods included from Trait

#card_accessor, #card_reader, #card_writer, #require_field

Methods included from Event::Api

#event

Class Method Details

.source_locationObject



7
# File 'tmpsets/set/mod020-search/abstract/03_filter.rb', line 7

def self.source_location; "/Users/ethan/dev/decko/gem/card/mod/search/set/abstract/03_filter.rb"; end

Instance Method Details

#all_filter_keysObject

all filter keys in the order they were selected



48
49
50
# File 'tmpsets/set/mod020-search/abstract/03_filter.rb', line 48

def all_filter_keys
  @all_filter_keys ||= filter_keys_from_params | filter_keys
end

#blocked_id_wqlObject



42
43
44
45
# File 'tmpsets/set/mod020-search/abstract/03_filter.rb', line 42

def blocked_id_wql
  not_ids = filter_param :not_ids
  not_ids.present? ? { id: ["not in", not_ids.split(",")] } : {}
end

#current_sortObject



38
39
40
# File 'tmpsets/set/mod020-search/abstract/03_filter.rb', line 38

def current_sort
  sort_param || default_sort_option
end

#default_sort_optionObject



136
137
138
# File 'tmpsets/set/mod020-search/abstract/03_filter.rb', line 136

def default_sort_option
  wql_from_content[:sort]
end

#filter_and_sort_wqlObject



15
16
17
# File 'tmpsets/set/mod020-search/abstract/03_filter.rb', line 15

def filter_and_sort_wql
  sort? ? filter_wql.merge(sort_wql) : filter_wql
end

#filter_classObject



11
12
13
# File 'tmpsets/set/mod020-search/abstract/03_filter.rb', line 11

def filter_class
  Card::FilterQuery
end

#filter_keysObject



52
53
54
# File 'tmpsets/set/mod020-search/abstract/03_filter.rb', line 52

def filter_keys
  [:name]
end

#filter_keys_from_paramsObject



56
57
58
# File 'tmpsets/set/mod020-search/abstract/03_filter.rb', line 56

def filter_keys_from_params
  filter_hash.keys.map(&:to_sym) - [:not_ids]
end

#filter_wqlObject



19
20
21
22
23
# File 'tmpsets/set/mod020-search/abstract/03_filter.rb', line 19

def filter_wql
  return {} if filter_hash.empty?

  filter_wql_from_params
end

#filter_wql_from_paramsObject

separate method is needed for tests



26
27
28
# File 'tmpsets/set/mod020-search/abstract/03_filter.rb', line 26

def filter_wql_from_params
  filter_class.new(filter_keys_with_values, blocked_id_wql).to_wql
end

#sort?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'tmpsets/set/mod020-search/abstract/03_filter.rb', line 34

def sort?
  true
end

#sort_wqlObject



30
31
32
# File 'tmpsets/set/mod020-search/abstract/03_filter.rb', line 30

def sort_wql
  sort? ? sort_hash : {}
end