Module: Lettr::Deliverable
- Defined in:
- lib/lettr/deliverable.rb
Class Method Summary collapse
Instance Method Summary collapse
- #build_delivery_record ⇒ Object
- #build_initial_delivery_hash ⇒ Object
- #deliver ⇒ Object
- #recipient? ⇒ Boolean
Class Method Details
.included(base) ⇒ Object
3 4 5 6 7 |
# File 'lib/lettr/deliverable.rb', line 3 def self.included base base.class_eval do attr_accessor :recipient end end |
Instance Method Details
#build_delivery_record ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/lettr/deliverable.rb', line 28 def build_delivery_record build_initial_delivery_hash group_variables if respond_to? :group_variables append_used_variables if respond_to? :append_used_variables # perform delivery request rec = Lettr::Delivery.new @hash, @files rec end |
#build_initial_delivery_hash ⇒ Object
39 40 41 42 43 44 |
# File 'lib/lettr/deliverable.rb', line 39 def build_initial_delivery_hash @hash = {} @files = {} @hash[ :recipient ] = recipient @hash[ :api_mailing_id ] = identifier end |
#deliver ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/lettr/deliverable.rb', line 13 def deliver fail ArgumentError, 'Empfänger nicht übergeben' unless recipient? rec = build_delivery_record rec.save if rec.errors.any? # invalidate cache and retry old_recipient = @hash[:recipient] reload recipient = old_recipient rec = build_delivery_record rec.save end rec end |
#recipient? ⇒ Boolean
9 10 11 |
# File 'lib/lettr/deliverable.rb', line 9 def recipient? !!@recipient end |