Module: Bsm::Sso::Client::Cached::ActiveRecord::ClassMethods
- Defined in:
- lib/bsm/sso/client/cached/active_record.rb
Instance Method Summary collapse
-
#sso_authorize(token) ⇒ Object
Cache!.
-
#sso_cache(resource, action = nil) ⇒ Object
Cache!.
-
#sso_find(id) ⇒ Object
Retrieve cached.
Instance Method Details
#sso_authorize(token) ⇒ Object
Cache!
20 21 22 23 24 25 26 |
# File 'lib/bsm/sso/client/cached/active_record.rb', line 20 def (token) return nil if token.blank? relation = where(arel_table[:updated_at].gt(Bsm::Sso::Client.expire_after.ago)) relation = relation.where(authentication_token: token) relation.first || super end |
#sso_cache(resource, action = nil) ⇒ Object
Cache!
29 30 31 32 33 34 35 |
# File 'lib/bsm/sso/client/cached/active_record.rb', line 29 def sso_cache(resource, action = nil) record = where(id: resource.id).first_or_initialize attrs = [resource.attributes.slice(*record.attribute_names)] record.assign_attributes(*attrs) record.changed? ? record.save! : record.touch record end |
#sso_find(id) ⇒ Object
Retrieve cached
15 16 17 |
# File 'lib/bsm/sso/client/cached/active_record.rb', line 15 def sso_find(id) where(id: id).first || super end |