Class: Client

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

Constant Summary collapse

DEFAULT_NAME =
'default'
DEFAULT_DESCRIPTION =
'Default Client'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.current_active?Boolean

Returns:

  • (Boolean)


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

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

.defaultObject



13
14
15
# File 'lib/models/client.rb', line 13

def self.default
  first_or_create :active => true
end

Instance Method Details

#activateObject



21
22
23
24
25
26
# File 'lib/models/client.rb', line 21

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

#deactivate_allObject



28
29
30
31
32
33
# File 'lib/models/client.rb', line 28

def deactivate_all
  Client.all.each do |client|
    client.active = false
    client.save
  end
end