app/models/twitter_auth/generic_user.rb in mbleigh-twitter-auth-0.1.21 vs app/models/twitter_auth/generic_user.rb in mbleigh-twitter-auth-0.1.22
- old
+ new
@@ -22,16 +22,18 @@
:favourites_count,
:time_zone,
:utc_offset
]
- validates_presence_of :login, :twitter_id
- validates_format_of :login, :with => /\A[a-z0-9_]+\z/i
- validates_length_of :login, :in => 1..15
- validates_uniqueness_of :login, :case_sensitive => false
- validates_uniqueness_of :twitter_id, :message => "ID has already been taken."
- validates_uniqueness_of :remember_token, :allow_blank => true
+ with_options :if => :utilize_default_validations do |v|
+ v.validates_presence_of :login, :twitter_id
+ v.validates_format_of :login, :with => /\A[a-z0-9_]+\z/i
+ v.validates_length_of :login, :in => 1..15
+ v.validates_uniqueness_of :login, :case_sensitive => false
+ v.validates_uniqueness_of :twitter_id, :message => "ID has already been taken."
+ v.validates_uniqueness_of :remember_token, :allow_blank => true
+ end
def self.table_name; 'users' end
def self.new_from_twitter_hash(hash)
raise ArgumentError, 'Invalid hash: must include screen_name.' unless hash.key?('screen_name')
@@ -66,9 +68,13 @@
if TwitterAuth.oauth?
include TwitterAuth::OauthUser
else
include TwitterAuth::BasicUser
+ end
+
+ def utilize_default_validations
+ true
end
def twitter
if TwitterAuth.oauth?
TwitterAuth::Dispatcher::Oauth.new(self)