cells-mailer 0.1.0 → 0.2.0
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 +4 -4
- data/.travis.yml +2 -0
- data/CHANGELOG.md +10 -0
- data/README.md +23 -4
- data/lib/cell/mailer/version.rb +1 -1
- data/lib/cell/mailer.rb +12 -3
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 992d44f718d8090f5a9e0dbfd60b2227a2300928
|
4
|
+
data.tar.gz: a76f206da09e97dbf92289db2e90200a3fb648ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 548c2e07dd21f8d957ea41a545f310647d4a9586e0bdcf0cfeb625fc83a0050a751089e2e987feae61cf4b0176584a36f625257bda0231756a664d4b5c740e0b
|
7
|
+
data.tar.gz: 61558fff49267f02a8a1b41a18b45005ecfef0d807c871d39f63852a917f0a54dacb0ee583806e1358bb415aec78046b29fa2190ec642514e61cb62afbb4d5b4
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -34,14 +34,33 @@ end
|
|
34
34
|
UserNotificationCell.(user).deliver(from: "foo@example.com", to: user.email, subject: "Hello")
|
35
35
|
```
|
36
36
|
|
37
|
+
### Body
|
38
|
+
|
39
|
+
Equal to Cells, you can deliver (render) different states of your Cell:
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
class UserNotificationCell < Cell::ViewModel
|
43
|
+
include Cell::Mailer
|
44
|
+
property :user_name
|
45
|
+
|
46
|
+
def welcome
|
47
|
+
"Hello #{user_name}"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
UserNotificationCell.(user).deliver(..., method: :welcome)
|
52
|
+
```
|
53
|
+
|
54
|
+
I don't know why you should use it, but you can also pass in a body as argument.
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
UserNotificationCell.(user).deliver(..., body: "Hello user")
|
58
|
+
```
|
59
|
+
|
37
60
|
## Roadmap
|
38
61
|
|
39
62
|
- Allow instand methods as source for
|
40
63
|
- `from`
|
41
64
|
- `to`
|
42
65
|
- `subject`
|
43
|
-
- Allow class level configurations for
|
44
|
-
- `from`
|
45
|
-
- `to`
|
46
|
-
- `subject`
|
47
66
|
- Provide class level `mail` delivery configurations
|
data/lib/cell/mailer/version.rb
CHANGED
data/lib/cell/mailer.rb
CHANGED
@@ -5,10 +5,19 @@ require "mail"
|
|
5
5
|
module Cell
|
6
6
|
module Mailer
|
7
7
|
def deliver(options)
|
8
|
-
|
9
|
-
mail = Mail.new options
|
10
|
-
mail.body call(state)
|
8
|
+
mail = Mail.new process_mail_options(options)
|
11
9
|
mail.deliver
|
12
10
|
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def process_mail_options(options)
|
15
|
+
state = options.delete(:method) || :show
|
16
|
+
[:to, :subject, :from].each do |field|
|
17
|
+
options[field] = send(options[field]) if options[field].is_a? Symbol
|
18
|
+
end
|
19
|
+
options[:body] ||= call(state)
|
20
|
+
options
|
21
|
+
end
|
13
22
|
end
|
14
23
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cells-mailer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Timo Schilling
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- ".gitignore"
|
91
91
|
- ".rspec"
|
92
92
|
- ".travis.yml"
|
93
|
+
- CHANGELOG.md
|
93
94
|
- Gemfile
|
94
95
|
- Guardfile
|
95
96
|
- README.md
|