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 +4 -4
- data/README.md +2 -1
- data/lib/jbuilder/jpartial/version.rb +1 -1
- data/lib/jbuilder/jpartial.rb +16 -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: c861847466f247a2a0bf573cf5bed5cd32a651dd
|
4
|
+
data.tar.gz: 98504d4e424a66d73cfa674373b5dc298ae72aa0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
|
data/lib/jbuilder/jpartial.rb
CHANGED
@@ -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)
|