Class: Cyclid::API::Organization

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/cyclid/models/organization.rb

Overview

Model for Organizations

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.all_as_hashObject

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.userpermissions << 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.userpermissions.delete(Userpermission.find_by(organization: self))
end