Sha256: 11cccda70735b533762b0da0553c6bbaad5e65a0f1e54a6edabdfdd9b856c600

Contents?: true

Size: 752 Bytes

Versions: 1

Compression:

Stored size: 752 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

1 entries across 1 versions & 1 rubygems

Version Path
couchkeeper-0.6.7 lib/doorkeeper/models/mongo_mapper/application.rb