Class: Popstar::Migration
- Inherits:
-
Object
- Object
- Popstar::Migration
- Defined in:
- lib/popstar/migration.rb
Constant Summary collapse
- @@rules =
{}
Class Method Summary collapse
Class Method Details
.rules ⇒ Object
18 19 20 |
# File 'lib/popstar/migration.rb', line 18 def rules @@rules || {} end |
.rules=(rules) ⇒ Object
22 23 24 |
# File 'lib/popstar/migration.rb', line 22 def rules=(rules) @@rules ||= rules end |
.up ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/popstar/migration.rb', line 6 def up @@rules.each do |target, rules| rules.each do |rule| if rule[:action] == :create rule[:model].all.each do |model| model.send(target).inc(:popularity, rule[:rate].call(model)) end end end end end |