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



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

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)


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

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



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

def results_path keyword
  path mark: :search, query: { keyword: keyword }
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