Skip to content

Commit 15ab62e

Browse files
Merge pull request #5 from qwert666/master
2 parents f2ac684 + a099e6e commit 15ab62e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/grape-swagger.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,14 @@ class Object
140140
# @person ? @person.name : nil
141141
# vs
142142
# @person.try(:name)
143-
def try(method)
144-
send method if respond_to? method
143+
#
144+
# File activesupport/lib/active_support/core_ext/object/try.rb#L32
145+
def try(*a, &b)
146+
if a.empty? && block_given?
147+
yield self
148+
else
149+
__send__(*a, &b)
150+
end
145151
end
146152
end
147153

0 commit comments

Comments
 (0)