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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a0ad03c3c7f56cdfe138412923bac122c81a8ebb
4
- data.tar.gz: 368cb9cf8c9dd0cb645dbae542cdffe21e6d3645
3
+ metadata.gz: 3c4bc3fb33ea70121ecd4d4c59c14240f6982ac8
4
+ data.tar.gz: 423ce292c94adee60afd1e8994343b84b034ecc2
5
5
  SHA512:
6
- metadata.gz: 01721112ae245fdf74a33b517d929cf7878134399d76a66803c5a010864285022213f9f6be33758a68e7985caea00ffc7e4a47d75b4b15666502fe6388e87c28
7
- data.tar.gz: 016c02249056dcfc63dff0194594ec3e0b586f02e2bcb99bd8bde5152c8ce93cf7c8e6858b6120df2181415823183d96258f1099ca988cf5600ae82b726c84b1
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
  ]
@@ -1,3 +1,3 @@
1
1
  class JsResponder
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: js_responder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felix Tioh