Class: Zendesk2::SearchHelpCenterArticles
- Inherits:
-
Object
- Object
- Zendesk2::SearchHelpCenterArticles
- Includes:
- Request
- Defined in:
- lib/zendesk2/help_center/search_help_center_articles.rb
Instance Attribute Summary collapse
-
#query ⇒ Object
readonly
Returns the value of attribute query.
Attributes included from Request
Instance Method Summary collapse
Methods included from Request
cistern_included, #data, #delete!, #error!, #find!, #html_url_for, included, #mock_response, #page, #page_params!, #page_params?, #pluralize, #real, #real_request, #request_body, #request_params, #request_path, #resources, #response, #timestamp, #url_for
Instance Attribute Details
#query ⇒ Object (readonly)
Returns the value of attribute query.
7 8 9 |
# File 'lib/zendesk2/help_center/search_help_center_articles.rb', line 7 def query @query end |
Instance Method Details
#call(query, params) ⇒ Object
9 10 11 12 |
# File 'lib/zendesk2/help_center/search_help_center_articles.rb', line 9 def call(query, params) @query = query super(params) end |
#mock ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/zendesk2/help_center/search_help_center_articles.rb', line 14 def mock terms = Hash[query.split(' ').map { |t| t.split(':') }] collection = data[:help_center_articles].values results = collection.select { |v| terms.all? { |term, condition| v[term.to_s].to_s == condition.to_s } } page(results, params: { 'query' => query }, root: 'results') end |