Sha256: bd7d0d64d79d932f4447017b96cf53873380feec547c6aef579bb40375b53cf5

Contents?: true

Size: 710 Bytes

Versions: 6

Compression:

Stored size: 710 Bytes

Contents

module Doorkeeper
  class Application
    include MongoMapper::Document
    safe
    timestamps!

    set_collection_name 'oauth_applications'

    many :authorized_tokens, class_name: 'Doorkeeper::AccessToken'

    key :name,         String
    key :uid,          String
    key :secret,       String
    key :redirect_uri, String
    key :scopes,       String

    def scopes=(value)
      write_attribute :scopes, value if value.present?
    end

    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.create_indexes
      ensure_index :uid, unique: true
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
doorkeeper-1.4.2 lib/doorkeeper/models/mongo_mapper/application.rb
doorkeeper-1.4.1 lib/doorkeeper/models/mongo_mapper/application.rb
doorkeeper-1.4.0 lib/doorkeeper/models/mongo_mapper/application.rb
doorkeeper-1.3.1 lib/doorkeeper/models/mongo_mapper/application.rb
doorkeeper-1.3.0 lib/doorkeeper/models/mongo_mapper/application.rb
doorkeeper-1.2.0 lib/doorkeeper/models/mongo_mapper/application.rb