Add comments

This commit is contained in:
2018-08-25 11:37:29 -05:00
parent 0c9aa61b7d
commit 064ab4fa28
2 changed files with 9 additions and 1 deletions
@@ -3,6 +3,8 @@ module Dunlop::AuthorizationHelper
Dunlop::Ability.has_permission_of_type(type, user)
end
# - if any_permission_starts_with 'source-file'
# NOTE: always true for admin users
def any_permission_starts_with(expression, user = current_user)
Dunlop::Ability.any_permission_starts_with(expression, user)
end
+7 -1
View File
@@ -34,8 +34,12 @@ module Dunlop::SourceFileModel
event(:failed) { transition any => :failed }
end
after_commit(on: :create) { autoload! }
after_commit(on: :create) { autoload! } # always autoload!, is empty method, can be implemented
# Auto generate the SourceFile::Job that allows processing by worker. For example
# def autoload
# SourceFile::Job.perform_later(id)
# end
self::Job = Class.new "#{name.deconstantize}::ApplicationJob".constantize do
def perform(source_file_id)
return unless source_file = self.class.name.sub(/::Job$/, '').constantize.find(source_file_id)
@@ -45,6 +49,8 @@ module Dunlop::SourceFileModel
end
end
# NOTE:/TODO: this strategy is incompatible with handling multiple files of the same type at the same time. Should be completely substituted by
# a sequential (elastic beanstalk is not sequential when worker has more than 1 thread) queue based worder implementation
def deactivate_loaded_source_file
self.class.active.update_all state: 'inactive'
end