Class: ProjectAuthorizations::Changes
- Inherits:
-
Object
- Object
- ProjectAuthorizations::Changes
- Defined in:
- app/models/project_authorizations/changes.rb
Overview
How to use this class authorizations_to_add: Rows to insert in the form ‘[{ user_id: user_id, project_id: project_id, access_level: access_level}, …]
ProjectAuthorizations::Changes.new do |changes|
changes.add()
changes.remove_users_in_project(project, user_ids)
changes.remove_projects_for_user(user, project_ids)
end.apply!
Constant Summary collapse
- BATCH_SIZE =
1000
- EVENTS_BATCH_SIZE =
100
- SLEEP_DELAY =
0.1
Instance Attribute Summary collapse
-
#authorizations_to_add ⇒ Object
readonly
Returns the value of attribute authorizations_to_add.
-
#projects_to_remove ⇒ Object
readonly
Returns the value of attribute projects_to_remove.
-
#users_to_remove_in_project ⇒ Object
readonly
Returns the value of attribute users_to_remove_in_project.
Instance Method Summary collapse
- #add(authorizations_to_add) ⇒ Object
- #apply! ⇒ Object
-
#initialize {|_self| ... } ⇒ Changes
constructor
A new instance of Changes.
- #remove_projects_for_user(user, project_ids) ⇒ Object
- #remove_users_in_project(project, user_ids) ⇒ Object
Constructor Details
#initialize {|_self| ... } ⇒ Changes
Returns a new instance of Changes.
20 21 22 23 24 25 26 |
# File 'app/models/project_authorizations/changes.rb', line 20 def initialize @authorizations_to_add = [] @affected_project_ids = Set.new @removed_user_ids = Set.new @added_user_ids = Set.new yield self end |
Instance Attribute Details
#authorizations_to_add ⇒ Object (readonly)
Returns the value of attribute authorizations_to_add.
14 15 16 |
# File 'app/models/project_authorizations/changes.rb', line 14 def @authorizations_to_add end |
#projects_to_remove ⇒ Object (readonly)
Returns the value of attribute projects_to_remove.
14 15 16 |
# File 'app/models/project_authorizations/changes.rb', line 14 def projects_to_remove @projects_to_remove end |
#users_to_remove_in_project ⇒ Object (readonly)
Returns the value of attribute users_to_remove_in_project.
14 15 16 |
# File 'app/models/project_authorizations/changes.rb', line 14 def users_to_remove_in_project @users_to_remove_in_project end |
Instance Method Details
#add(authorizations_to_add) ⇒ Object
28 29 30 |
# File 'app/models/project_authorizations/changes.rb', line 28 def add() @authorizations_to_add += end |
#apply! ⇒ Object
40 41 42 43 44 45 46 |
# File 'app/models/project_authorizations/changes.rb', line 40 def apply! if if if publish_events end |
#remove_projects_for_user(user, project_ids) ⇒ Object
36 37 38 |
# File 'app/models/project_authorizations/changes.rb', line 36 def remove_projects_for_user(user, project_ids) @projects_to_remove = { project_ids: project_ids, scope: user } end |
#remove_users_in_project(project, user_ids) ⇒ Object
32 33 34 |
# File 'app/models/project_authorizations/changes.rb', line 32 def remove_users_in_project(project, user_ids) @users_to_remove_in_project = { user_ids: user_ids, scope: project } end |