Class: Goldencobra::ArticleAdapter
- Inherits:
-
Object
- Object
- Goldencobra::ArticleAdapter
- Defined in:
- app/adapters/goldencobra/article_adapter.rb
Class Method Summary collapse
-
.find(url, options = {}) ⇒ Integer
Alias method for find_by_url.
-
.find_by_id(article_id) ⇒ Object
find an goldencobra article by a given ArticleID.
-
.find_by_url(url, follow_redirection: false) ⇒ Integer
find an article id by a given url If you use this method in a controller, the controller should redirect to a redirection.
-
.find_url_by_id(search_id) ⇒ Array
find an url by a given ID.
Class Method Details
.find(url, options = {}) ⇒ Integer
Alias method for find_by_url
12 13 14 |
# File 'app/adapters/goldencobra/article_adapter.rb', line 12 def find(url, = {}) find_by_url(url, ) end |
.find_by_id(article_id) ⇒ Object
find an goldencobra article by a given ArticleID
45 46 47 |
# File 'app/adapters/goldencobra/article_adapter.rb', line 45 def find_by_id(article_id) Goldencobra::Article.find_by_id(article_id) end |
.find_by_url(url, follow_redirection: false) ⇒ Integer
find an article id by a given url If you use this method in a controller, the controller should redirect to a redirection.
If you use this method somewhere else, you should activate follow_redirection:true to be sure you get the right article
27 28 29 30 31 |
# File 'app/adapters/goldencobra/article_adapter.rb', line 27 def find_by_url(url, follow_redirection: false) url_to_search = cleanup_url(url) url_to_search = follow_redirections(url_to_search) if follow_redirection Goldencobra::ArticleUrl.where(url: url_to_search).pluck(:article_id).first end |
.find_url_by_id(search_id) ⇒ Array
find an url by a given ID
37 38 39 |
# File 'app/adapters/goldencobra/article_adapter.rb', line 37 def find_url_by_id(search_id) Goldencobra::ArticleUrl.where(article_id: search_id).pluck(:url) end |