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
12
13
14
15
16
17
18
|
# File 'lib/jbuilder/jpartial.rb', line 12
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
20
21
22
23
|
# File 'lib/jbuilder/jpartial.rb', line 20
def _method_is_a_route_helper?(method_name)
method_name.to_s =~ /(.*)_(url|path)/ && !@context.nil? &&
@context.respond_to?(method_name)
end
|
#json ⇒ Object
6
7
8
|
# File 'lib/jbuilder/jpartial.rb', line 6
def json
self
end
|
#old_method_missing ⇒ Object
10
|
# File 'lib/jbuilder/jpartial.rb', line 10
alias_method :old_method_missing, :method_missing
|