module Doorkeeper class Application < Couchbase::Model include Doorkeeper::OAuth::Helpers attribute :name, :secret, :redirect_uri attribute :created_at, :default => lambda { Time.now.utc } alias_attribute :uid, :id view :by_uid_and_secret, :by_uid, :show_all def self.authorized_for(resource_owner) AccessToken.where_owner_id(resource_owner.id) end def self.authenticate(uid, secret) by_uid_and_secret({:key => [uid, secret]}) end def self.by_uid(uid) by_uid({:key => uid}) end def self.find_all show_all({:key => nil, :include_docs => true, :stale => false}) end private def generate_uid self.id = UniqueToken.generate end def generate_secret self.secret = UniqueToken.generate end end end