Class: Cyclid::API::Organization
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Cyclid::API::Organization
- Defined in:
- app/cyclid/models/organization.rb
Overview
Model for Organizations
Class Method Summary collapse
-
.all_as_hash ⇒ Object
Return the collection of Organizations as an array of Hashes (instead of Organization objects).
Instance Method Summary collapse
-
#add_user_org_perm(user) ⇒ Object
Ensure that a set of Userpermissions exist when a User is added to this Organization.
-
#remove_user_org_perm(user) ⇒ Object
Remove Userpermissions when a User is removed from this Organization.
Class Method Details
.all_as_hash ⇒ Object
Return the collection of Organizations as an array of Hashes (instead of Organization objects)
27 28 29 |
# File 'app/cyclid/models/organization.rb', line 27 def all_as_hash all.to_a.map(&:serializable_hash) end |
Instance Method Details
#add_user_org_perm(user) ⇒ Object
Ensure that a set of Userpermissions exist when a User is added to this Organization
52 53 54 55 |
# File 'app/cyclid/models/organization.rb', line 52 def add_user_org_perm(user) Cyclid.logger.debug "Creating org. perm. for #{user.username}" user. << Userpermission.new(organization: self) end |
#remove_user_org_perm(user) ⇒ Object
Remove Userpermissions when a User is removed from this Organization
58 59 60 61 |
# File 'app/cyclid/models/organization.rb', line 58 def remove_user_org_perm(user) Cyclid.logger.debug "Destroying org. perm. for #{user.username}" user..delete(Userpermission.find_by(organization: self)) end |