Class: AuditLog
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- AuditLog
show all
- Defined in:
- app/models/audit_log.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
allow items to be looked up by method calls
27
28
29
30
31
32
33
34
|
# File 'app/models/audit_log.rb', line 27
def method_missing(m, *args, &block)
if self.respond_to?(m)
item = get_item_by_item_type_internal_identifier(m.to_s)
(item.nil?) ? super : (return item.audit_log_item_value)
else
super
end
end
|
Class Method Details
.custom_application_log_message(party, msg) ⇒ Object
37
38
39
40
41
42
43
|
# File 'app/models/audit_log.rb', line 37
def custom_application_log_message(party, msg)
self.create(
:party_id => party.id,
:audit_log_type => AuditLogType.find_by_type_and_subtype_iid('application','custom_message'),
:description => "#{party.description}: #{msg}"
)
end
|
.party_access(party, url) ⇒ Object
61
62
63
64
65
66
67
|
# File 'app/models/audit_log.rb', line 61
def party_access(party, url)
self.create(
:party_id => party.id,
:audit_log_type => AuditLogType.find_by_type_and_subtype_iid('application','accessed_area'),
:description => "#{party.description} has accessed area #{url}"
)
end
|
.party_failed_access(party, url) ⇒ Object
69
70
71
72
73
74
75
|
# File 'app/models/audit_log.rb', line 69
def party_failed_access(party, url)
self.create(
:party_id => party.id,
:audit_log_type => AuditLogType.find_by_type_and_subtype_iid('application','accessed_area'),
:description => "#{party.description} has tried to access a restricted area #{url}"
)
end
|
.party_login(party) ⇒ Object
53
54
55
56
57
58
59
|
# File 'app/models/audit_log.rb', line 53
def party_login(party)
self.create(
:party_id => party.id,
:audit_log_type => AuditLogType.find_by_type_and_subtype_iid('application','successful_login'),
:description => "#{party.description} has logged in"
)
end
|
.party_logout(party) ⇒ Object
45
46
47
48
49
50
51
|
# File 'app/models/audit_log.rb', line 45
def party_logout(party)
self.create(
:party_id => party.id,
:audit_log_type => AuditLogType.find_by_type_and_subtype_iid('application','successful_logout'),
:description => "#{party.description} has logged out"
)
end
|
.party_session_timeout(party) ⇒ Object
77
78
79
80
81
82
83
|
# File 'app/models/audit_log.rb', line 77
def party_session_timeout(party)
self.create(
:party_id => party.id,
:audit_log_type => AuditLogType.find_by_type_and_subtype_iid('application','session_timeout'),
:description => "#{party.description} session has expired"
)
end
|
Instance Method Details
#get_item_by_item_type_internal_identifier(item_type_internal_identifier) ⇒ Object
16
17
18
19
|
# File 'app/models/audit_log.rb', line 16
def get_item_by_item_type_internal_identifier(item_type_internal_identifier)
self.items.includes(:audit_log_item_type)
.where(:audit_log_item_types => {:internal_identifier => item_type_internal_identifier}).first
end
|
#respond_to?(m, include_private_methods = false) ⇒ Boolean
allow items to be looked up by method calls
22
23
24
|
# File 'app/models/audit_log.rb', line 22
def respond_to?(m, include_private_methods = false)
(super ? true : get_item_by_item_type_internal_identifier(m.to_s)) rescue super
end
|