Skip to content

Instantly share code, notes, and snippets.

@Grandvizir
Last active August 29, 2015 14:04
Show Gist options
  • Save Grandvizir/ba1081d348fd2cec4c38 to your computer and use it in GitHub Desktop.
Save Grandvizir/ba1081d348fd2cec4c38 to your computer and use it in GitHub Desktop.
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