Module: Card::Set::Self::Search::Format

Extended by:
AbstractFormat
Defined in:
platypus/tmp/set/gem-defaults/mod009-search/self/search.rb

Instance Method Summary collapse

Instance Method Details

#complete_pathObject



41
42
43
44
# File 'platypus/tmp/set/gem-defaults/mod009-search/self/search.rb', line 41

def complete_path
  path mark: :search, view: :search_box_complete, format: :json
  # path mark: :search, view: :test, format: :json
end

#cql_keyword?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'platypus/tmp/set/gem-defaults/mod009-search/self/search.rb', line 37

def cql_keyword?
  search_keyword&.match?(/^\{.+\}$/)
end

#cql_searchObject



24
25
26
27
# File 'platypus/tmp/set/gem-defaults/mod009-search/self/search.rb', line 24

def cql_search
  query = card.parse_json_cql search_keyword
  rescuing_bad_query(query) { Card.search query }
end

#results_path(keyword) ⇒ Object



46
47
48
# File 'platypus/tmp/set/gem-defaults/mod009-search/self/search.rb', line 46

def results_path keyword
  path mark: :search, query: { keyword: keyword }
end

#search_keywordObject



29
30
31
# File 'platypus/tmp/set/gem-defaults/mod009-search/self/search.rb', line 29

def search_keyword
  @search_keyword ||= term_param || search_vars&.dig(:keyword)
end

#search_varsObject



33
34
35
# File 'platypus/tmp/set/gem-defaults/mod009-search/self/search.rb', line 33

def search_vars
  root.respond_to?(:search_params) ? root.search_params[:vars] : search_params[:vars]
end

#search_with_paramsObject



20
21
22
# File 'platypus/tmp/set/gem-defaults/mod009-search/self/search.rb', line 20

def search_with_params
  @search_with_params ||= cql_keyword? ? cql_search : super
end

#view: search_errorObject



15
16
17
18
# File 'platypus/tmp/set/gem-defaults/mod009-search/self/search.rb', line 15

view :search_error, cache: :never do
  # don't show card content; not very helpful in this case
  %(#{search_with_params.class} :: #{search_with_params.message})
end