Class: Jbuilder
- Inherits:
-
Object
show all
- Defined in:
- lib/jbuilder/jpartial.rb,
lib/jbuilder/jpartial/railtie.rb,
lib/jbuilder/jpartial/version.rb
Overview
Defined Under Namespace
Modules: Jpartial
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
11
12
13
14
15
16
17
|
# File 'lib/jbuilder/jpartial.rb', line 11
def method_missing(method_name, *args, &block)
if _method_is_a_route_helper?(method_name)
@context.send(method_name, *args, &block)
else
old_method_missing(method_name, *args, &block)
end
end
|
Instance Method Details
#_method_is_a_route_helper?(method_name) ⇒ Boolean
19
20
21
22
23
|
# File 'lib/jbuilder/jpartial.rb', line 19
def _method_is_a_route_helper?(method_name)
method_name.to_s =~ /(.*)_(url|path)/ &&
defined? @context &&
context.respond_to?(method_name)
end
|
#json ⇒ Object
5
6
7
|
# File 'lib/jbuilder/jpartial.rb', line 5
def json
self
end
|
#old_method_missing ⇒ Object
9
|
# File 'lib/jbuilder/jpartial.rb', line 9
alias_method :old_method_missing, :method_missing
|