Skip to content

Commit

Permalink
Automatically process units on creation
Browse files Browse the repository at this point in the history
  • Loading branch information
rwdaigle committed Jun 1, 2012
1 parent fba083e commit c9d7d3e
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions app/models/unit.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class Unit < ActiveRecord::Base
validates_uniqueness_of :question, :scope => :subject_id validates_uniqueness_of :question, :scope => :subject_id


before_save :normalize_question before_save :normalize_question
after_create :process!


belongs_to :subject belongs_to :subject
has_many :learnings, :dependent => :delete_all has_many :learnings, :dependent => :delete_all
Expand Down Expand Up @@ -54,13 +55,7 @@ def <=>(other)
end end


def process!(overwrite = false) def process!(overwrite = false)
log(subject, self, { 'overwrite' => overwrite }) do $queue.enqueue("WordnikProcessor.process!", id) if answer.blank? || overwrite
if answer.blank? || overwrite
subject.with_processor do |processor_klass|
processor_klass.process!(self, unit)
end
end
end
end end


def to_log def to_log
Expand Down

0 comments on commit c9d7d3e

Please sign in to comment.