Last active
August 29, 2015 14:04
-
-
Save Grandvizir/ba1081d348fd2cec4c38 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RepositoryUser | |
def new_user( _user_attrs ) | |
User.new( _user_attrs ) | |
end | |
def find_by( _attr, _value ) | |
return User.where( [ "? = ?", _attr, _value ] ).first() | |
end | |
def save( _user ) | |
_user.save() | |
end | |
def update_user( _user_attrs, _user ) | |
_user.attributes = _user_attrs | |
return _user | |
end | |
def find( _id ) | |
User.find( _id ) | |
end | |
def find_login( _login_attrs ) | |
login = _login_attrs.extract!('email', 'password', :valid_account) | |
User.where( login ).where(:valid_account => true).select( "id, email, name, created_at, updated_at" ).first() | |
end | |
def find_by_email( _email ) | |
User.where( :email => _email ).first() | |
end | |
def delete( _user ) | |
_user.update_attributes( :valid_account => false ) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment