jbuilder-jpartial 0.2.0 → 0.2.1

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: 29f17aa56ad6436b58ce9ae71dec2f5bcecf03bf
4
- data.tar.gz: 21924849d686e532c9ace096a0036295bb0a1a50
3
+ metadata.gz: c861847466f247a2a0bf573cf5bed5cd32a651dd
4
+ data.tar.gz: 98504d4e424a66d73cfa674373b5dc298ae72aa0
5
5
  SHA512:
6
- metadata.gz: ea006e37c63c21f57e17786017e27c272212fb3059b4f5f5ee1f90394a58234dbf095bcdb1b1cfb4c66af5b3fd9379ad0565b1c1252543e767b827defa8b7340
7
- data.tar.gz: 021b55c1ba1436e5feb0421a5069d8e78e81f2dfaa643341fb78b1e2d0185c7e2b03ca2d4d14d8967d57258ab017b725f2e0f60a6de254a1407cee594ba82419
6
+ metadata.gz: 640dbcf9cabb2acee3aafbca3fe5d42f07d6647d8588b548cad2cd649e302473c7d548e0483b2b149bb580c3e93b9c5e66a74a64eccfa807aa3928dae4be50ff
7
+ data.tar.gz: aed6a8bd528ee1e69664721e32530f48208a52edbdd08467d07e678eb63f279f77b449183c65631614741742834532aa50aa65f786f0a19c4c1b47ba4023c574
data/README.md CHANGED
@@ -162,9 +162,10 @@ end
162
162
 
163
163
  However unlikely, if you try to name a partial with the same name as a method already defined by Jbuilder it will throw an error at start up. Just pick a different name, like `#whatever_partial` instead of `#whatever`.
164
164
 
165
- One method taken by this library is `Jbuilder#json`. This method returns the `self` of the receiver, which will be the instance of `Jbuilder` doing the encoding. If you have or need any fields with the key `"json"` use `Jbuilder#set!`, e.g.
165
+ Methods taken by this library are `Jbuilder#json` and any route helpers e.g. `Jbuilder#post_url`. If you have or need any fields with keys like `"json"` or `"post_url"` use `Jbuilder#set!`, e.g.
166
166
  ```ruby
167
167
  json.set! 'json', 'some value'
168
+ json.set! 'post_url', 'some url'
168
169
  ```
169
170
 
170
171
 
@@ -1,5 +1,5 @@
1
1
  class Jbuilder
2
2
  module Jpartial
3
- VERSION = '0.2.0'.freeze
3
+ VERSION = '0.2.1'.freeze
4
4
  end
5
5
  end
@@ -6,6 +6,22 @@ class Jbuilder
6
6
  self
7
7
  end
8
8
 
9
+ alias_method :old_method_missing, :method_missing
10
+
11
+ def method_missing(method_name, *args, &block)
12
+ if _method_is_a_route_helper?(method_name)
13
+ @context.send(method_name, *args, &block)
14
+ else
15
+ old_method_missing(method_name, *args, &block)
16
+ end
17
+ end
18
+
19
+ def _method_is_a_route_helper?(method_name)
20
+ method_name.to_s =~ /(.*)_(url|path)/ &&
21
+ defined? @context &&
22
+ context.respond_to?(method_name)
23
+ end
24
+
9
25
  # Jpartial module
10
26
  module Jpartial
11
27
  DangerousMethodName = Class.new(ArgumentError)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jbuilder-jpartial
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - M. Simon Borg