Class: Shoppe::Customer

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/shoppe/customer.rb

Constant Summary collapse

EMAIL_REGEX =
/\A\b[A-Z0-9\.\_\%\-\+]+@(?:[A-Z0-9\-]+\.)+[A-Z]{2,6}\b\z/i
PHONE_REGEX =
/\A[+?\d\ \-x\(\)]{7,}\z/

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.ransackable_associations(auth_object = nil) ⇒ Object



39
40
41
# File 'app/models/shoppe/customer.rb', line 39

def self.ransackable_associations(auth_object = nil)
  []
end

.ransackable_attributes(auth_object = nil) ⇒ Object



35
36
37
# File 'app/models/shoppe/customer.rb', line 35

def self.ransackable_attributes(auth_object = nil)
  ["id", "first_name", "last_name", "company", "email", "phone", "mobile"] + _ransackers.keys
end

Instance Method Details

#full_nameString

The full name of the customer created by concatinting the first & last name

Returns:

  • (String)


31
32
33
# File 'app/models/shoppe/customer.rb', line 31

def full_name
  "#{first_name} #{last_name}"
end

#nameString

The name of the customer in the format of “Company (First Last)” or if they don’t have company specified, just “First Last”.

Returns:

  • (String)


24
25
26
# File 'app/models/shoppe/customer.rb', line 24

def name
  company.blank? ? full_name : "#{company} (#{full_name})"
end