Class: Dcmgr::Models::Account

Inherits:
BaseNew
  • Object
show all
Defined in:
lib/dcmgr/models/account.rb

Defined Under Namespace

Modules: SystemAccount

Constant Summary collapse

DISABLED =
0
ENABLED =
1

Constants inherited from BaseNew

BaseNew::LOCK_TABLES_KEY

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseNew

Proxy, dataset, default_row_lock_mode=, install_data, install_data_hooks, lock!, #to_hash, unlock!, #with_timestamps?

Class Method Details

.default_valuesObject



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

def default_values
  @default_values ||= {}
end

.description(description = nil) ⇒ Object



64
65
66
67
68
69
# File 'lib/dcmgr/models/account.rb', line 64

def description(description=nil)
  if description
    default_values[:description] = description
  end
  default_values[:description]
end

.pk(pk = nil) ⇒ Object



45
46
47
48
49
50
# File 'lib/dcmgr/models/account.rb', line 45

def pk(pk=nil)
  if pk
    default_values[:id] = pk
  end
  default_values[:id]
end

.uuid(uuid = nil) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
# File 'lib/dcmgr/models/account.rb', line 52

def uuid(uuid=nil)
  if uuid.is_a?(String)
    uuid = uuid.downcase
    unless self.check_trimmed_uuid_format(uuid)
      raise "Invalid syntax of uuid: #{uuid}"
    end
    default_values[:uuid] = uuid
  end
  raise("#{self}.uuid is unset. Set the unique number") unless default_values[:uuid]
  "#{uuid_prefix}-#{default_values[:uuid]}"
end

Instance Method Details

#after_createObject



28
29
30
31
# File 'lib/dcmgr/models/account.rb', line 28

def after_create
  self.quota = Quota.create
  super
end

#before_destroyObject



33
34
35
36
# File 'lib/dcmgr/models/account.rb', line 33

def before_destroy
  self.quota.destroy unless self.quota.nil?
  super
end

#disable?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/dcmgr/models/account.rb', line 20

def disable?
  self.enabled == DISABLED
end

#enable?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/dcmgr/models/account.rb', line 24

def enable?
  self.enabled == ENABLED
end