module Challah::Authorizeable::ClassMethods
Public Instance Methods
del(options = {})
click to toggle source
Remove an authorization
# File lib/challah/concerns/authorizeable.rb, line 21 def del(options = {}) provider = options.fetch(:provider) user_id = options.fetch(:user_id) where(provider: provider, user_id: user_id).delete_all end
get(options = {})
click to toggle source
Grab the user/provider record
# File lib/challah/concerns/authorizeable.rb, line 29 def get(options = {}) provider = options.fetch(:provider) user_id = options.fetch(:user_id) where(provider: provider, user_id: user_id).first end
hashable_attributes()
click to toggle source
# File lib/challah/concerns/authorizeable.rb, line 15 def hashable_attributes protected_attributes = %w( user_id provider last_session_at last_session_ip session_count created_at updated_at ) @hashable_attributes ||= self.columns.map(&:name) - protected_attributes end
set(options = {})
click to toggle source
Create a new authorization record for the given user
# File lib/challah/concerns/authorizeable.rb, line 37 def set(options = {}) provider = options.delete(:provider) user_id = options.delete(:user_id).to_i uid = options.delete(:uid) token = options.delete(:token) expires_at = options.delete(:expires_at) || nil del(provider: provider, user_id: user_id) record = self.new() record.provider = provider record.user_id = user_id record.uid = uid record.token = token record.expires_at = expires_at record.attributes = options if options.any? record.save! record end
user_model()
click to toggle source
# File lib/challah/concerns/authorizeable.rb, line 63 def user_model @user_model ||= Challah.user end
users_table_name()
click to toggle source
# File lib/challah/concerns/authorizeable.rb, line 59 def users_table_name @users_table_name ||= user_model.table_name end