cells-mailer 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c1734602fd36a8a2f670c8cbffe441891277d729
4
- data.tar.gz: 773125b20d1ea109471d7a71053f9af1e1d0bfa6
3
+ metadata.gz: 992d44f718d8090f5a9e0dbfd60b2227a2300928
4
+ data.tar.gz: a76f206da09e97dbf92289db2e90200a3fb648ab
5
5
  SHA512:
6
- metadata.gz: 496126e659edbe480788b6e94811b60710e911d0f42a84edbfebeaee7287cd055857be32b261a9de318a52d9039407dc98231ec1933f17540821e883ac4cfdad
7
- data.tar.gz: 80d7e66151ac66901c86c52481ac4f2c80d108b46f730679c2ae44a839dc58b852cccaa624931e8f4fb0414bb08a7b3fbd848f011eb8cfa2f8af6e8421c108d8
6
+ metadata.gz: 548c2e07dd21f8d957ea41a545f310647d4a9586e0bdcf0cfeb625fc83a0050a751089e2e987feae61cf4b0176584a36f625257bda0231756a664d4b5c740e0b
7
+ data.tar.gz: 61558fff49267f02a8a1b41a18b45005ecfef0d807c871d39f63852a917f0a54dacb0ee583806e1358bb415aec78046b29fa2190ec642514e61cb62afbb4d5b4
data/.travis.yml CHANGED
@@ -1,4 +1,6 @@
1
1
  language: ruby
2
2
  sudo: false
3
+ cache: bundler
3
4
  rvm:
4
5
  - 2.2
6
+ before_install: gem update bundler
data/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ # Changelog
2
+
3
+ ## v0.2.0 [☰](https://github.com/timoschilling/cells-mailer/compare/v0.1.0...v0.2.0)
4
+
5
+ * Allow instance methods for `subject`, `from` and `to`
6
+ * Allow passing in a body as string
7
+
8
+ ## v0.1.0
9
+
10
+ * Basic functionality
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
@@ -1,5 +1,5 @@
1
1
  module Cell
2
2
  module Mailer
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
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
- state = options.delete(:method) || :show
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.1.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