Skip to content

Commit 4afe0b8

Browse files
committed
Optimize method_missing via alias_method
1 parent d4c8827 commit 4afe0b8

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

lib/jbuilder.rb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,6 @@ def set!(key, value = BLANK, *args, &block)
6464
_set_value key, result
6565
end
6666

67-
def method_missing(*args, &block)
68-
if ::Kernel.block_given?
69-
set!(*args, &block)
70-
else
71-
set!(*args)
72-
end
73-
end
74-
7567
# Specifies formatting to be applied to the key. Passing in a name of a function
7668
# will cause that function to be called on the key. So :upcase will upper case
7769
# the key. You can also pass in lambdas for more complex transformations.
@@ -281,6 +273,8 @@ def target!
281273

282274
private
283275

276+
alias_method :method_missing, :set!
277+
284278
def _extract_hash_values(object, attributes)
285279
attributes.each{ |key| _set_value key, _format_keys(object.fetch(key)) }
286280
end

0 commit comments

Comments
 (0)