text_message_rails 0.1.1 → 0.1.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61f00a8c0971b843dbdeae388b1dba6cc4f44a37
|
4
|
+
data.tar.gz: 66b743b50f707d7bf04114f42a472433b8990f60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8808ff498efa8a2bb5e45e7d18d32086f934cb7864c50880acbab6cd773d3b40411b6eb1dd46cb19840d041fdb622c1295df33f413cc4bc7dae61c74a9d2266
|
7
|
+
data.tar.gz: 4d5ff71644396b4a1c744cacb31aad987e9c3912797457af47b69a2435fd14cda13730c93db2e789e43ce8ed5fddf7d6a5f77b4757a1addc6457def3fab5432e
|
@@ -27,13 +27,16 @@ module TextMessage
|
|
27
27
|
# Defines #render_to_body, needed by #render.
|
28
28
|
include ::TextMessage::Rendering
|
29
29
|
|
30
|
+
attr_reader :params
|
31
|
+
|
30
32
|
# Instanciate a new TextMessage object.
|
31
33
|
#
|
32
34
|
# Then calls +method_name+ with the given +args+.
|
33
|
-
def initialize(method_name, *
|
35
|
+
def initialize(method_name, *params)
|
34
36
|
@recipients = []
|
37
|
+
@params = params
|
35
38
|
super()
|
36
|
-
process(method_name, *
|
39
|
+
process(method_name, *params)
|
37
40
|
end
|
38
41
|
|
39
42
|
# Basic Recipients handling
|
@@ -42,6 +45,10 @@ module TextMessage
|
|
42
45
|
@recipients = recipients || []
|
43
46
|
end
|
44
47
|
|
48
|
+
def delivery
|
49
|
+
TextMessage::Delivery.new(self, action_name, *params)
|
50
|
+
end
|
51
|
+
|
45
52
|
class << self
|
46
53
|
|
47
54
|
def default_url_options=(options)
|
@@ -11,8 +11,13 @@ module TextMessage
|
|
11
11
|
# By providing a +TextMessage::Base+ subclass +text_message_class+, a method name to call
|
12
12
|
# +text_message_method+ and a set of arguments to this method +args+, we allow
|
13
13
|
# for lazy processing of the text_message action.
|
14
|
-
def initialize(
|
15
|
-
|
14
|
+
def initialize(text_message_controller, text_message_method, *args)
|
15
|
+
if text_message_controller.kind_of?(TextMessage::Controller)
|
16
|
+
@obj = text_message_controller
|
17
|
+
@text_message_class = @obj.class
|
18
|
+
else
|
19
|
+
@text_message_class = text_message_controller.kind_of?(Class) ? text_message_controller : text_message_controller.constantize
|
20
|
+
end
|
16
21
|
@text_message_method = text_message_method
|
17
22
|
@args = args
|
18
23
|
end
|
@@ -24,7 +29,7 @@ module TextMessage
|
|
24
29
|
|
25
30
|
# computes the body of the TextMessage
|
26
31
|
def body
|
27
|
-
renderer.render(view_context, template: "#{templates_dir}/#{@text_message_method}")
|
32
|
+
@body ||= renderer.render(view_context, template: "#{templates_dir}/#{@text_message_method}")
|
28
33
|
end
|
29
34
|
|
30
35
|
# The name of the templates which holds the templates.
|
@@ -33,7 +38,7 @@ module TextMessage
|
|
33
38
|
# TextMessageDemo.new.templates_dir => "text_message demo"
|
34
39
|
# # so for exemple TextMessageDemo#toto will lookup for text_message_demo/toto{.text.erb}
|
35
40
|
def templates_dir
|
36
|
-
@text_message_class.to_s.underscore
|
41
|
+
@text_message_class.name.to_s.underscore
|
37
42
|
end
|
38
43
|
|
39
44
|
end
|
@@ -17,7 +17,11 @@ module TextMessage
|
|
17
17
|
|
18
18
|
# Use custom rendeing class with helpers loaded
|
19
19
|
def view_context # :nodoc:
|
20
|
-
@view_context ||=
|
20
|
+
@view_context ||= if defined?(ApplicationController)
|
21
|
+
ApplicationController.view_context_class.new(renderer, view_assigns, self)
|
22
|
+
else
|
23
|
+
TemplateContext.new(renderer, view_assigns, self)
|
24
|
+
end
|
21
25
|
end
|
22
26
|
|
23
27
|
# Simple out-of-the box ActionView::Renderer
|
@@ -28,20 +32,22 @@ module TextMessage
|
|
28
32
|
|
29
33
|
#
|
30
34
|
# Private class to render provide rendering context with helpers
|
35
|
+
# (when there is no ApplicationController: rails API etc.)
|
31
36
|
#
|
32
37
|
|
33
38
|
class TemplateContext < ActionView::Base #:nodoc:
|
34
39
|
# Load route helpers
|
35
40
|
include Rails.application.routes.url_helpers
|
36
|
-
# load tag helpers (link_to ...)
|
41
|
+
# load tag helpers (link_to ...) and all relevant default helpers
|
37
42
|
include ActionView::Helpers::TagHelper
|
43
|
+
include ActionView::Helpers::DateHelper
|
44
|
+
include ActionView::Helpers::NumberHelper
|
45
|
+
include ActionView::Helpers::TextHelper
|
46
|
+
include ActionView::Helpers::TranslationHelper
|
38
47
|
|
39
48
|
# Default options for urls
|
40
49
|
def default_url_options
|
41
|
-
TextMessage::Controller.default_url_options
|
42
|
-
#action: action_name,
|
43
|
-
#controller: controller.class.name.underscore
|
44
|
-
})
|
50
|
+
TextMessage::Controller.default_url_options
|
45
51
|
end
|
46
52
|
end
|
47
53
|
|