Class: Account
Defined Under Namespace
Modules: SystemAccount
Constant Summary
collapse
- DISABLED =
0
- ENABLED =
1
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from BaseNew
Proxy, install_data, install_data_hooks, #with_timestamps?
Class Method Details
.default_values ⇒ Object
60
61
62
|
# File 'app/models/account.rb', line 60
def default_values
@default_values ||= {}
end
|
.description(description = nil) ⇒ Object
82
83
84
85
86
87
|
# File 'app/models/account.rb', line 82
def description(description=nil)
if description
default_values[:description] = description
end
default_values[:description]
end
|
.pk(pk = nil) ⇒ Object
64
65
66
67
68
69
|
# File 'app/models/account.rb', line 64
def pk(pk=nil)
if pk
default_values[:id] = pk
end
default_values[:id]
end
|
.uuid(uuid = nil) ⇒ Object
71
72
73
74
75
76
77
78
79
80
|
# File 'app/models/account.rb', line 71
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
default_values[:uuid] || raise("#{self}.uuid is unset. Set the unique number")
end
|
Instance Method Details
#_delete ⇒ Object
override Sequel::Model#_delete not to delete rows but to set delete flags.
52
53
54
55
56
|
# File 'app/models/account.rb', line 52
def _delete
self.deleted_at ||= Time.now
self.is_deleted = true
self.save
end
|
#before_destroy ⇒ Object
Delete relations before setting an account to deleted
41
42
43
44
45
46
47
48
|
# File 'app/models/account.rb', line 41
def before_destroy
relations = self.users
for ss in 0...relations.length do
self.remove_user(relations[0])
end
super
end
|
#disable? ⇒ Boolean
26
27
28
|
# File 'app/models/account.rb', line 26
def disable?
not self.enable
end
|
#enable? ⇒ Boolean
30
31
32
|
# File 'app/models/account.rb', line 30
def enable?
self.enable
end
|
#to_hash_document ⇒ Object
34
35
36
37
38
|
# File 'app/models/account.rb', line 34
def to_hash_document
h = self.values.dup
h[:id] = h[:uuid] = self.canonical_uuid
h
end
|