This file contains hidden or 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 AnonymiseUsers | |
include UseCasePattern | |
def perform | |
User.find_each(&method(:anonymise)) | |
end | |
private | |
def anonymise(user) |
This file contains hidden or 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 AnonymiseUsers | |
include UseCasePattern | |
def perform | |
User.find_each(:anonymise) | |
end | |
end | |
class User | |
def anonymise |
This file contains hidden or 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 User | |
def anonymise | |
Users.find_each do |user| | |
user.update_columns email: "#{user.id}@devnullmail.com" | |
end | |
end | |
end |
This file contains hidden or 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
# Wraps a request in a new transaction. Add to your controller like: | |
# around_filter :transactify, :only => [:update, :create, :destroy] | |
def transactify | |
logger.debug 'Beginning transaction' | |
ActiveRecord::Base.transaction do | |
yield | |
end | |
logger.debug 'Committing transaction' |
This file contains hidden or 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
puts "found entry #{entry.dn}" | |
dn = entry[:dn] | |
first_name = entry[:givenName] ? entry[:givenName].first : '' | |
surname = entry[:sn] ? entry[:sn].first : '' | |
roles = entry[:secondaryclassname] |
This file contains hidden or 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 StaticAuthenticator | |
def authenticate(username, password) | |
case(username) | |
when 'nigel': return username, 'Nigel', 'Ramsay', ['QUALITYUSER', 'QUALITYSYSADMIN'] | |
when 'santosh': return username, 'Santosh', 'Mani', ['QUALITYUSER', 'QUALITYSYSADMIN'] | |
when 'user': return username, 'Quality', 'User', ['QUALITYUSER'] | |
when 'admin': return username, 'Quality', 'Sys Admin', ['QUALITYSYSADMIN'] | |
when 'somebody': return username, 'Objective', 'User', ['OBJECTIVE'] | |
when 'nobody': return username, 'Nobody', 'User', [] |