Skip to content

Instantly share code, notes, and snippets.

@zampino
Created January 26, 2016 17:05
Show Gist options
  • Save zampino/4bd4773bc4cd8fc48d9d to your computer and use it in GitHub Desktop.
Save zampino/4bd4773bc4cd8fc48d9d to your computer and use it in GitHub Desktop.
def enqueued_resources_for(klass, resource_type: nil)
jobs = enqueued_jobs.find_all { |_job| _job[:job] == klass }
resources = jobs.map {|job|
gid = job[:args].first['_aj_globalid']
gid && GlobalID::Locator.locate(gid)
}
if resource_type
resources = resources.find_all { |resource| resource.is_a?(resource_type) }
end
resources
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment