outbox-rails 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 91a62722084b298ce8cc71b4225743d1ded08c8f
4
- data.tar.gz: 4c282c245537e0b0b56e2c325fd50e5ed168814e
3
+ metadata.gz: 525a3a52879108983b9c2afc5353808de7b5caf1
4
+ data.tar.gz: 10b21890104eb4695e7f89d69955833fa57d3e38
5
5
  SHA512:
6
- metadata.gz: b4f52277e2f943095288ca66c3365799a1ee3785f673cf5aae89858c3958b69d7b829d2bce60eb6d0b8e3c0cd53c06f1e9abc8a5bdfb2c2e70b63874de299e97
7
- data.tar.gz: a26a2fb0b2f945f694dfa6e4eb17a32e0d3dd44d0d50f0f38225db33233d6f272969076814bc67989073565f8bb66a360f4260de041a21afb8a818ccc58aeb90
6
+ metadata.gz: e83c7badbd9b68e11587732816c191589645a7593d74cce5a98209abbbf2eedc04ef2900b1a17b3cbfabb5fc740281c12ad7acdde31e2015fe2f17bf781b628a
7
+ data.tar.gz: 944abb48fee1557ea0e5e7dabfedd61d50ab25e2eeb0696251cd47e0df8db7d61460f010a19c0c57069b5c3d36dca65152cf48ae8f648fe74d2ac831d82d9b0b
@@ -124,8 +124,11 @@ module Outbox
124
124
  templates = find_message_type_templates(options)
125
125
  templates.each do |template|
126
126
  variants = (template.try(:variants) || []).compact
127
- body = render(template: template)
128
- assign_body(body, variants.empty? ? nil : variants)
127
+ if variants.empty?
128
+ assign_body(render(template: template))
129
+ else
130
+ assign_body(render(template: template, variants: variants), variants)
131
+ end
129
132
  end
130
133
  end
131
134
 
@@ -1,5 +1,5 @@
1
1
  module Outbox
2
2
  module Rails
3
- VERSION = '0.4.0'
3
+ VERSION = '0.4.1'
4
4
  end
5
5
  end
@@ -1,4 +1,6 @@
1
1
  class BaseNotifier < Outbox::Notifier
2
+ layout :set_layout
3
+
2
4
  def welcome(hash = {})
3
5
  render_message(hash)
4
6
  end
@@ -29,6 +31,13 @@ class BaseNotifier < Outbox::Notifier
29
31
  end
30
32
  end
31
33
 
32
- def implicit_variants
34
+ def implicit_variants(layout = false)
35
+ @layout = layout
36
+ end
37
+
38
+ protected
39
+
40
+ def set_layout
41
+ @layout
33
42
  end
34
43
  end
@@ -0,0 +1 @@
1
+ Email Layout: <%= yield %>
@@ -0,0 +1 @@
1
+ SMS Layout: <%= yield %>
@@ -104,6 +104,12 @@ describe Outbox::Notifier do
104
104
  expect(message.email.body.encoded.strip).to eql('Email Variant')
105
105
  expect(message.sms.body.strip).to eql('SMS Variant')
106
106
  end
107
+
108
+ it 'supports layout variants' do
109
+ message = BaseNotifier.implicit_variants('notification')
110
+ expect(message.email.body.encoded.strip).to eql('Email Layout: Email Variant')
111
+ expect(message.sms.body.strip).to eql('SMS Layout: SMS Variant')
112
+ end
107
113
  end
108
114
  end
109
115
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: outbox-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Browne
@@ -184,6 +184,8 @@ files:
184
184
  - spec/internal/app/views/base_notifier/implicit_variants.text+sms.erb
185
185
  - spec/internal/app/views/base_notifier/welcome.erb
186
186
  - spec/internal/app/views/customized_notifier/with_defaults.erb
187
+ - spec/internal/app/views/layouts/notification.text+email.erb
188
+ - spec/internal/app/views/layouts/notification.text+sms.erb
187
189
  - spec/internal/config/database.yml
188
190
  - spec/internal/config/routes.rb
189
191
  - spec/internal/db/schema.rb
@@ -230,6 +232,8 @@ test_files:
230
232
  - spec/internal/app/views/base_notifier/implicit_variants.text+sms.erb
231
233
  - spec/internal/app/views/base_notifier/welcome.erb
232
234
  - spec/internal/app/views/customized_notifier/with_defaults.erb
235
+ - spec/internal/app/views/layouts/notification.text+email.erb
236
+ - spec/internal/app/views/layouts/notification.text+sms.erb
233
237
  - spec/internal/config/database.yml
234
238
  - spec/internal/config/routes.rb
235
239
  - spec/internal/db/schema.rb