Class: ArticleList
- Inherits:
-
Noodall::Node
- Object
- Noodall::Node
- ArticleList
- Defined in:
- app/models/article_list.rb
Instance Method Summary collapse
- #all_categories ⇒ Object
- #archive(options = {}) ⇒ Object
- #articles ⇒ Object
- #list ⇒ Object
- #recent_articles(options = {}) ⇒ Object
Instance Method Details
#all_categories ⇒ Object
24 25 26 |
# File 'app/models/article_list.rb', line 24 def all_categories super(children.published.criteria.to_hash) end |
#archive(options = {}) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/models/article_list.rb', line 28 def archive( = {}) = remove_invalid_filters() criteria = Plucky::CriteriaHash.new( :path => self._id, :_type => 'Article', :published_at => { :$lte => Time.zone.now }, :published_to => { :$gte => Time.zone.now } ).to_hash.merge() result = self.collection.map_reduce(archive_map('published_at'), archive_reduce, {:query => criteria, :finalize => archive_finalize, :out => "tmp_articles"}) years = result.find.to_a.map{ |hash| Year.new(hash['_id'],hash['value']) }.sort{ |a,b| b.year <=> a.year } years end |
#articles ⇒ Object
10 11 12 |
# File 'app/models/article_list.rb', line 10 def articles children.published end |
#list ⇒ Object
20 21 22 |
# File 'app/models/article_list.rb', line 20 def list self end |
#recent_articles(options = {}) ⇒ Object
14 15 16 17 18 |
# File 'app/models/article_list.rb', line 14 def recent_articles( = {}) = remove_invalid_filters() [:order] = ['published_at DESC','created_at DESC'] children.published.limit(3).all() end |