Module: FatFreeCRM::Permissions::InstanceMethods
- Defined in:
- lib/fat_free_crm/permissions.rb
Instance Method Summary collapse
-
#access=(value) ⇒ Object
Remove all shared permissions if no longer shared ————————————————————————–.
-
#remove_permissions ⇒ Object
Removes all permissions on an object ————————————————————————–.
-
#save_with_model_permissions(model) ⇒ Object
Save the model copying other model’s permissions.
-
#save_with_permissions(users = nil) ⇒ Object
Save the model along with its permissions if any.
-
#update_with_permissions(attributes, users = nil) ⇒ Object
Update the model along with its permissions if any.
Instance Method Details
#access=(value) ⇒ Object
Remove all shared permissions if no longer shared
63 64 65 66 |
# File 'lib/fat_free_crm/permissions.rb', line 63 def access=(value) unless value == 'Shared' super(value) end |
#remove_permissions ⇒ Object
Removes all permissions on an object
70 71 72 73 74 |
# File 'lib/fat_free_crm/permissions.rb', line 70 def # we don't use dependent => :destroy so must manually remove = Permission.find_all_by_asset_id_and_asset_type(self.id, self.class) .each {|p| (.delete(p); p.destroy)} end |
#save_with_model_permissions(model) ⇒ Object
Save the model copying other model’s permissions.
92 93 94 95 96 97 |
# File 'lib/fat_free_crm/permissions.rb', line 92 def (model) self.access = model.access self.user_ids = model.user_ids self.group_ids = model.group_ids save end |
#save_with_permissions(users = nil) ⇒ Object
Save the model along with its permissions if any.
78 79 80 81 |
# File 'lib/fat_free_crm/permissions.rb', line 78 def (users = nil) ActiveSupport::Deprecation.warn "save_with_permissions is deprecated and may be removed from future releases, use user_ids and group_ids inside attributes instead." save end |
#update_with_permissions(attributes, users = nil) ⇒ Object
Update the model along with its permissions if any.
85 86 87 88 |
# File 'lib/fat_free_crm/permissions.rb', line 85 def (attributes, users = nil) ActiveSupport::Deprecation.warn "update_with_permissions is deprecated and may be removed from future releases, use user_ids and group_ids inside attributes instead." update_attributes(attributes) end |