Module: Krant::Tasks
- Extended by:
- Rake::DSL
- Defined in:
- lib/krant/tasks.rb
Overview
Create database records for each new news item. Together with the “last seen” timestamp of a user, the corresponding creation timestamps will be used to determine seen/unseen state of each news item.
Class Method Summary collapse
-
.install(&block) ⇒ Object
Defines a news:persist task that persists news items to the database.
Class Method Details
.install(&block) ⇒ Object
Defines a news:persist task that persists news items to the database.
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/krant/tasks.rb', line 15 def self.install(&block) desc 'Persist news items' task 'news:persist' => 'environment' do news = block.call puts "Persisting news for #{news.scope}..." news.persist do |news_item| puts "- #{news_item.name}: #{news_item.title}" end end end |