Sha256: ef513b1f7897b48ff9cf16b63db03bd6cb8b76a0d91bbbf8b1520d7fb48a673c

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

module CloudCrowd

  # A Black Listed Action is an action that has been disabled from running.  For example, we may
  # want to disable calls to a particular API once we have reached a rate limit.
  # When a Node exits, it destroys this record.
  class BlackListedAction < ActiveRecord::Base

    validates_presence_of :action
    validates :action, uniqueness: true
    validates :action, format: { with: /\A[a-z_]+\z/, message: "action names must be alphabetic snakecase" }

    # Update items on our blacklist that have expired and can now be run
    # def self.update_black_list
    #   black_list = BlackListedAction.where.not(:duration_in_seconds => [nil,'',0])
    #   black_list.each do |item|
    #     target_time = item.created_at.to_i + item.duration_in_seconds
    #     item.delete if target_time < Time.now.to_i
    #   end 
    # end

    # Returns the time the blacklisting will be removed
    # def finish_time
    #   return nil if self.duration_in_seconds.nil?
    #   Time.at(self.created_at.to_i + self.duration_in_seconds)
    # end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cloud-crowd-0.7.6 lib/cloud_crowd/models/black_listed_action.rb