Class: Jobshop::Mailroom::BaseHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/jobshop/mailroom/base_handler.rb

Direct Known Subclasses

NullHandler, RFQHandler

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, mailman) ⇒ BaseHandler

Returns a new instance of BaseHandler.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/jobshop/mailroom/base_handler.rb', line 16

def initialize(message, mailman)
  self.organization = mailman.organization

  self.to   = Mail::Address.new(message.to.first)
  self.from = Mail::Address.new(message.from.first)

  self.customer_contact = organization.customer_contacts
    .find_by(email: from.address)

  self.customer = customer_contact&.customer ||
    organization.customers.find_by(from_domain)

  self.subject = message.subject
  self.content = parse_body(message)
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



6
7
8
# File 'lib/jobshop/mailroom/base_handler.rb', line 6

def content
  @content
end

#customerObject

Returns the value of attribute customer.



6
7
8
# File 'lib/jobshop/mailroom/base_handler.rb', line 6

def customer
  @customer
end

#customer_contactObject

Returns the value of attribute customer_contact.



6
7
8
# File 'lib/jobshop/mailroom/base_handler.rb', line 6

def customer_contact
  @customer_contact
end

#fromObject

Returns the value of attribute from.



6
7
8
# File 'lib/jobshop/mailroom/base_handler.rb', line 6

def from
  @from
end

#organizationObject

Returns the value of attribute organization.



6
7
8
# File 'lib/jobshop/mailroom/base_handler.rb', line 6

def organization
  @organization
end

#subjectObject

Returns the value of attribute subject.



6
7
8
# File 'lib/jobshop/mailroom/base_handler.rb', line 6

def subject
  @subject
end

#toObject

Returns the value of attribute to.



6
7
8
# File 'lib/jobshop/mailroom/base_handler.rb', line 6

def to
  @to
end