Class: IdentityClient::AccessGrant
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- IdentityClient::AccessGrant
- Defined in:
- app/models/identity_client/access_grant.rb
Class Method Summary collapse
Class Method Details
.by_user(user) ⇒ Object
22 23 24 |
# File 'app/models/identity_client/access_grant.rb', line 22 def self.by_user(user) AccessGrant.where(user_id: user.id).first end |
.create_or_update_by_user_and_credentials(user, credentials) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/models/identity_client/access_grant.rb', line 7 def self.create_or_update_by_user_and_credentials(user, credentials) attributes = { access_token: credentials['token'], expires_at: Time.at(credentials['expires_at']) } if (grant = AccessGrant.by_user(user)) grant.update_attributes(attributes) else grant = user.create_access_grant(attributes) end grant end |