-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce helpers (selectors) for anonymise all a subject's records. #97
Conversation
d3c30ad
to
eddb72f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
describe ".anonymise_for!" do | ||
let!(:model_b) do | ||
klass.create!(first_name: "matt", last_name: "brown", company_name: "alpha") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lib/anony/anonymisable.rb
Outdated
# each of them. If a selector is not defined it will railse an exception. | ||
def anonymise_for!(subject, subject_id) | ||
anonymise_config. | ||
select(subject, subject_id, &:anonymise!) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth double checking that each subject
responds to anoynmise!
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can do - what behaviour would you expect? An error being raised?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like this 70d18ab?
These can be used to anonymise all records that relate to a specific subject. You first define a block for a specific subject that returns a list of anonymisable records. ```ruby anonymise do selectors do for_subject(:user_id) { |user_id| self.select_for_user(user_id) } end end ``` This can then be used to anonymise all those subject using this API: ```ruby ModelName.anonymise_for!(:user_id, "user_1234") ``` Attempting to use a selector that has not been defined will throw an error.
eddb72f
to
5b9d0f2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 looks good to me!
88b9da4
to
f5bb883
Compare
f5bb883
to
bbad3a0
Compare
Seems it wasn't updated for #97 either :/
Seems it wasn't updated for #97 either :/
These can be used to anonymise all records that relate to a specific
subject.
You first define a block for a specific subject that returns a list of
anonymisable records.
You can also use scopes,
where
, etc when defining your selectors:This can then be used to anonymise all those subject using this API:
If you attempt to anonymise records with a selector that has not been defined it will throw an error.