js_responder 0.1.1 → 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/README.md +4 -0
- data/lib/js_responder/version.rb +1 -1
- data/lib/js_responder.rb +7 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c4bc3fb33ea70121ecd4d4c59c14240f6982ac8
|
4
|
+
data.tar.gz: 423ce292c94adee60afd1e8994343b84b034ecc2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d94e40b5984379a95528b9b6b6ea3a33bc533b57dc6e9a090792eda591fce2766290c9fb847ea57971521b5090c494f32ace65408277cbb534b72a99906b4559
|
7
|
+
data.tar.gz: f12e52abb09cbfc983bd53239ea80af7b84984f84f9e1c89865e6c3060cae4c7bf57a28e98287f368023a5cae5d3a70612d9cc88bd342b0485dfb2fa4b3b578a
|
data/README.md
CHANGED
@@ -4,6 +4,8 @@ Part of the Rails Ajax Responder Architecture.
|
|
4
4
|
On the server side controller, you transcode your chain of commands into an array to your JS Client.
|
5
5
|
Your JS Client should have a corresponding methods that are able to execute these commands.
|
6
6
|
|
7
|
+
JsResponder implements method_missing. You can write any method in transcode block as long as there is a corresponding method in the client.
|
8
|
+
|
7
9
|
## Installation
|
8
10
|
|
9
11
|
Add this line to your application's Gemfile:
|
@@ -25,6 +27,7 @@ Or install it yourself as:
|
|
25
27
|
condition = (1+1 == 2)
|
26
28
|
instructions = JsResponder.new.transcode do
|
27
29
|
redirect 'http://www.redirect.to'
|
30
|
+
any_method 'Hola'
|
28
31
|
if condition
|
29
32
|
success 'Yes, 1+1 equal 2'
|
30
33
|
else
|
@@ -34,6 +37,7 @@ instructions = JsResponder.new.transcode do
|
|
34
37
|
end
|
35
38
|
instructions == [
|
36
39
|
['redirect', 'http://www.redirect.to'],
|
40
|
+
['any_method', 'Hola'],
|
37
41
|
['success', 'Yes, 1+1 equal 2'],
|
38
42
|
['log', 'Operation completed']
|
39
43
|
]
|
data/lib/js_responder/version.rb
CHANGED
data/lib/js_responder.rb
CHANGED
@@ -16,6 +16,7 @@ class JsResponder
|
|
16
16
|
return instructions
|
17
17
|
end
|
18
18
|
|
19
|
+
# Default instruction set
|
19
20
|
def redirect(url)
|
20
21
|
instructions << ['redirect', url]
|
21
22
|
end
|
@@ -31,4 +32,10 @@ class JsResponder
|
|
31
32
|
def error(text)
|
32
33
|
instructions << ['error', text]
|
33
34
|
end
|
35
|
+
|
36
|
+
# Introduce some flexibility by catching other commands
|
37
|
+
def method_missing(method, *args)
|
38
|
+
instructions << [[method.to_s], args].flatten!
|
39
|
+
end
|
40
|
+
|
34
41
|
end
|