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

Extended by:
AbstractFormat
Defined in:
card/tmpsets/set/mod035-card-mod-search/self/search.rb,
card/tmpsets/set/mod036-card-mod-search/self/search.rb

Instance Method Summary collapse

Instance Method Details

#cql_keyword?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'card/tmpsets/set/mod035-card-mod-search/self/search.rb', line 36

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

#cql_searchObject



21
22
23
24
25
26
# File 'card/tmpsets/set/mod035-card-mod-search/self/search.rb', line 21

def cql_search
  query = card.parse_json_cql search_keyword
  rescuing_bad_query query do
    Card.search query
  end
end

#search_keywordObject



28
29
30
# File 'card/tmpsets/set/mod035-card-mod-search/self/search.rb', line 28

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

#search_varsObject



32
33
34
# File 'card/tmpsets/set/mod035-card-mod-search/self/search.rb', line 32

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

#search_with_paramsObject



17
18
19
# File 'card/tmpsets/set/mod035-card-mod-search/self/search.rb', line 17

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

#view: search_errorObject



10
11
12
13
14
15
# File 'card/tmpsets/set/mod035-card-mod-search/self/search.rb', line 10

view :search_error, cache: :never do
  sr_class = search_with_params.class.to_s

  # don't show card content; not very helpful in this case
  %(#{sr_class} :: #{search_with_params.message})
end