class Doorkeeper::Application

def self.authorized_for(resource_owner)

def self.authorized_for(resource_owner)
  joins(:authorized_applications).
    where(AccessToken.table_name => { resource_owner_id: resource_owner.id, revoked_at: nil }).
    group(column_names_with_table.join(','))
end

def self.authorized_for(resource_owner)

def self.authorized_for(resource_owner)
  ids = AccessToken.where(resource_owner_id: resource_owner.id, revoked_at: nil).map(&:application_id)
  find(ids)
end

def self.authorized_for(resource_owner)

def self.authorized_for(resource_owner)
  ids = AccessToken.where(resource_owner_id: resource_owner.id, revoked_at: nil).map(&:application_id)
  find(ids)
end

def self.authorized_for(resource_owner)

def self.authorized_for(resource_owner)
  ids = AccessToken.where(resource_owner_id: resource_owner.id, revoked_at: nil).map(&:application_id)
  find(ids)
end

def self.authorized_for(resource_owner)

def self.authorized_for(resource_owner)
  ids = AccessToken.where(resource_owner_id: resource_owner.id, revoked_at: nil).map(&:application_id)
  find(ids)
end

def self.column_names_with_table

def self.column_names_with_table
  self.column_names.map { |c| "#{table_name}.#{c}" }
end

def self.create_indexes

def self.create_indexes
  ensure_index :uid, unique: true
end