Module: MnoEnterprise::Concerns::Models::Organization

Extended by:
ActiveSupport::Concern
Included in:
Organization
Defined in:
lib/mno_enterprise/concerns/models/organization.rb

Overview

Schema Information

Endpoint:

- /v1/organizations
- /v1/users/:user_id/organizations

id                       :integer         not null, primary key
uid                      :string(255)
name                     :string(255)
created_at               :datetime        not null
updated_at               :datetime        not null
account_frozen           :boolean         default(FALSE)
free_trial_end_at        :datetime
soa_enabled              :boolean         default(TRUE)
mails                    :text
logo                     :string(255)
latitude                 :float           default(0.0)
longitude                :float           default(0.0)
geo_country_code         :string(255)
geo_state_code           :string(255)
geo_city                 :string(255)
geo_tz                   :string(255)
geo_currency             :string(255)
meta_data                :text
industry                 :string(255)
size                     :string(255)

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#add_user(user, role = 'Member') ⇒ Object

Add a user to the organization with the provided role TODO: specs



78
79
80
# File 'lib/mno_enterprise/concerns/models/organization.rb', line 78

def add_user(user,role = 'Member')
  self.users.create(id: user.id, role: role)
end

#last_invoiceObject



82
83
84
85
# File 'lib/mno_enterprise/concerns/models/organization.rb', line 82

def last_invoice
  inv = self.raw_last_invoice
  inv.id ? inv : nil
end

#membersObject

Instance methods

Return the list of users + active invites TODO: specs



72
73
74
# File 'lib/mno_enterprise/concerns/models/organization.rb', line 72

def members
  [self.users,self.org_invites.active].flatten
end

#remove_user(user) ⇒ Object

Remove a user from the organization TODO: specs



93
94
95
# File 'lib/mno_enterprise/concerns/models/organization.rb', line 93

def remove_user(user)
  self.users.destroy(id: user.id)
end

#update_user(user, role = 'Member') ⇒ Object

Change a user role in the organization TODO: specs



99
100
101
# File 'lib/mno_enterprise/concerns/models/organization.rb', line 99

def update_user(user, role = 'Member')
  self.users.update(id: user.id, role: role)
end