Class: ActionMailbox::Router::Route
Relationships & Source Files | |
Inherits: | Object |
Defined in: | actionmailbox/lib/action_mailbox/router/route.rb |
Overview
Encapsulates a route, which can then be matched against an inbound_email and provide a lookup of the matching mailbox class. See examples for the different route addresses and how to use them in the ::ActionMailbox::Base
documentation.
Class Method Summary
- .new(address, to:) ⇒ Route constructor
Instance Attribute Summary
- #address readonly
- #mailbox_name readonly
Instance Method Summary
Constructor Details
.new(address, to:) ⇒ Route
Instance Attribute Details
#address (readonly)
[ GitHub ]# File 'actionmailbox/lib/action_mailbox/router/route.rb', line 8
attr_reader :address, :mailbox_name
#mailbox_name (readonly)
[ GitHub ]# File 'actionmailbox/lib/action_mailbox/router/route.rb', line 8
attr_reader :address, :mailbox_name
Instance Method Details
#mailbox_class
[ GitHub ]# File 'actionmailbox/lib/action_mailbox/router/route.rb', line 31
def mailbox_class "#{mailbox_name.to_s.camelize}Mailbox".constantize end
#match?(inbound_email) ⇒ Boolean
# File 'actionmailbox/lib/action_mailbox/router/route.rb', line 16
def match?(inbound_email) case address when :all true when String inbound_email.mail.recipients.any? { |recipient| address.casecmp?(recipient) } when Regexp inbound_email.mail.recipients.any? { |recipient| address.match?(recipient) } when Proc address.call(inbound_email) else address.match?(inbound_email) end end