Sha256: a9434dcf0f5d7a5cb1ed2eff0ac364aed4bde46f35f8b9415f4590f2c7a46db1
Contents?: true
Size: 1.31 KB
Versions: 1
Compression:
Stored size: 1.31 KB
Contents
module Socialite module Models module UserConcern extend ActiveSupport::Concern included do has_many :identities, :dependent => :destroy, :class_name => Socialite.identity_class_name, :foreign_key => "#{Socialite.user_class.table_name.singularize}_id" end def method_missing(id, *args, &block) if id =~ /(\w+)_identity$/ && @identity = self.identities.where(:provider => $1).first @identity else super end end # Returns the first linked facebook identity # # @return [Identity] the first facebook identity def facebook self.facebook_identity end # Returns the first linked twitter account # # @return [Identity] the first twitter identity def twitter self.twitter_identity end # Set the user's remember token # # @return [User] the current user # def remember_me! # self.remember_token = Socialite.generate_token # save(:validate => false) # end # Clear the user's remember token # # @return [User] the current user # def forget_me! # if persisted? # self.remember_token = nil # save(:validate => false) # end # end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
socialite-0.1.0.pre | lib/socialite/models/user_concern.rb |