lib/courier/owner.rb in courier-0.1.2 vs lib/courier/owner.rb in courier-0.1.3

- old
+ new

@@ -12,21 +12,23 @@ module Courier::Owner def has_courier has_one :courier, :as => :owner, :dependent => :destroy, :class_name=>'Courier::OwnerSetting' + has_many :courier_messages, :as => :owner, :dependent => :destroy, :class_name=>'Courier::Message' include InstanceMethods after_create do create_courier end end module InstanceMethods def message(template_key, args={}) template = Courier.template(template_key) - Courier.config.services_order.each do |service| - service.message(self, template, args) if courier.enabled?(template, service, args) + Courier.config.services_order.select do |service| + create_courier unless courier + courier.enabled?(template, service, args) and service.message(self, template, args) end end end end