Class: Jbuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/jbuilder/jpartial.rb,
lib/jbuilder/jpartial/railtie.rb,
lib/jbuilder/jpartial/version.rb

Overview

Top level Jbuilder class

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

Returns:

  • (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

#jsonObject



5
6
7
# File 'lib/jbuilder/jpartial.rb', line 5

def json
  self
end

#old_method_missingObject



9
# File 'lib/jbuilder/jpartial.rb', line 9

alias_method :old_method_missing, :method_missing