Sha256: 1675864e3bcfc507538fad6147d4f653bc0f88f84316ad0f360ea9a6d0d2ae72
Contents?: true
Size: 1.43 KB
Versions: 1
Compression:
Stored size: 1.43 KB
Contents
module Doorkeeper class Application include DoorkeeperMongodb::Compatible include MongoMapper::Document include DoorkeeperMongodb::Mixins::MongoMapper::ApplicationMixin safe timestamps! set_collection_name 'oauth_applications' many :authorized_tokens, class_name: 'Doorkeeper::AccessToken', dependent: :destroy key :name, String key :uid, String key :secret, String key :redirect_uri, String key :confidential, Boolean, default: true key :scopes, String 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 # Due to lack of proper ORM independence in Doorkeeper gem :( # def update(attributes = {}) self.attributes = attributes save end def create_or_update(options = {}) run_callbacks(:save) do result = persisted? ? _update(options) : create(options) result != false end end def save!(options = {}) if options.key?(:validate) super(options.merge(safe: options.delete(:validate))) else super end end private def _update(options = {}) save_to_collection(options.reverse_merge(:persistence_method => :save)) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
doorkeeper-mongodb-5.0.0 | lib/doorkeeper/orm/mongo_mapper/application.rb |