Class: PostfixAdmin::ApplicationRecord

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
ExistingTimestamp
Defined in:
lib/postfix_admin/application_record.rb

Direct Known Subclasses

Admin, Alias, Domain, DomainAdmin, Log, MailDomain, Mailbox, Quota

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_strObject



25
26
27
# File 'lib/postfix_admin/application_record.rb', line 25

def active_str
  active? ? "Active" : "Inactive"
end

#has_timestamp_columns?Boolean

Returns:

  • (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

Returns:

  • (Boolean)


21
22
23
# File 'lib/postfix_admin/application_record.rb', line 21

def inactive?
  !active?
end

#set_current_time_to_timestamp_columnsObject



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