Sha256: 92c691468bfa5ac8cb0175f50a7c4c6c7c1b090bbabba1057ef2f53ebbbc98b1
Contents?: true
Size: 1.17 KB
Versions: 2
Compression:
Stored size: 1.17 KB
Contents
class Trigger < ActiveRecord::Base belongs_to :pending_item, polymorphic: true class << self def post_action(due_at, item, method = 'came_due') create!(due_at: due_at, pending_item: item, trigger_method: method) fire end def fire destroy_all ['due_at <= ?', Time.now] true rescue migrator = Migrator.new unless migrator.pending_migrations.empty? starting_version = migrator.current_schema_version migrator.migrate if starting_version == 0 load "#{Rails.root}/Rakefile" Rake::Task['db:seed'].invoke User.reset_column_information Article.reset_column_information Page.reset_column_information end end end def remove(pending_item, conditions = {}) return if pending_item.new_record? conditions = conditions.merge(pending_item_id: pending_item.id, pending_item_type: pending_item.class.to_s) where(conditions).delete_all end end before_destroy :trigger_pending_item def trigger_pending_item pending_item.send(trigger_method) if pending_item true end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
publify_core-9.0.0.pre2 | app/models/trigger.rb |
publify_core-9.0.0.pre1 | app/models/trigger.rb |