Class: PostfixAdmin::ApplicationRecord
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- PostfixAdmin::ApplicationRecord
show all
- Includes:
- ExistingTimestamp
- Defined in:
- lib/postfix_admin/application_record.rb
Constant Summary
collapse
- RE_DOMAIN_NAME_LIKE_BASE =
'([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}'
- RE_EMAIL_LIKE_BASE =
'[^@\s]+@([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}'
- RE_DOMAIN_NAME_LIKE =
/#{RE_DOMAIN_NAME_LIKE_BASE}/
- RE_EMAIL_LIKE =
/#{RE_EMAIL_LIKE_BASE}/
- RE_DOMAIN_NAME_LIKE_WITH_ANCHORS =
/\A#{RE_DOMAIN_NAME_LIKE_BASE}\z/
- RE_EMAIL_LIKE_WITH_ANCHORS =
/\A#{RE_EMAIL_LIKE_BASE}\z/
Instance Method Summary
collapse
Instance Method Details
#active_str ⇒ Object
25
26
27
|
# File 'lib/postfix_admin/application_record.rb', line 25
def active_str
active? ? "Active" : "Inactive"
end
|
#has_timestamp_columns? ⇒ Boolean
39
40
41
42
|
# File 'lib/postfix_admin/application_record.rb', line 39
def has_timestamp_columns?
column_names = self.class.column_names
column_names.include?("created") && column_names.include?("modified")
end
|
#inactive? ⇒ Boolean
21
22
23
|
# File 'lib/postfix_admin/application_record.rb', line 21
def inactive?
!active?
end
|
#set_current_time_to_timestamp_columns ⇒ Object
33
34
35
36
37
|
# File 'lib/postfix_admin/application_record.rb', line 33
def set_current_time_to_timestamp_columns
now = Time.now
self.created = now
self.modified = now
end
|