Class: Project

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/models/project.rb

Constant Summary collapse

DEFAULT_NAME =
'default'
DEFAULT_DESCRIPTION =
'Default Project'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.current_active?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/models/project.rb', line 21

def self.current_active?
  where(:active => true).first
end

.defaultObject



17
18
19
# File 'lib/models/project.rb', line 17

def self.default
  find_or_create_by_active true
end

Instance Method Details

#activateObject



25
26
27
28
29
30
# File 'lib/models/project.rb', line 25

def activate
  deactivate_all
  self.active = true
  self.save
  self
end

#deactivate_allObject



32
33
34
35
36
37
38
39
# File 'lib/models/project.rb', line 32

def deactivate_all
  Project.all.each do |project|
    if project.id != self.id
      project.active = false
      project.save
    end
  end
end

#set_default_clientObject



41
42
43
# File 'lib/models/project.rb', line 41

def set_default_client
  self.client = Client.default if self.client.nil?
end