diff options
author | Robert Speicher <rspeicher@gmail.com> | 2015-05-23 18:38:44 -0400 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2015-06-10 01:31:27 -0400 |
commit | 33df3ed384563b1e302e5a4f2186b156c35bafc5 (patch) | |
tree | 275dcc47727c3958aec3cc8a7f4d1849031e7601 | |
parent | 57830201a9152b56ccf65a98275601617f44653d (diff) | |
download | gitlab-ce-33df3ed384563b1e302e5a4f2186b156c35bafc5.tar.gz |
Add `respond_to_missing?` for Commit and Repository
As of Ruby 1.9, this is the correct way to handle `respond_to?` for
methods implemented by `method_missing`.
See https://robots.thoughtbot.com/always-define-respond-to-missing-when-overriding
-rw-r--r-- | app/models/commit.rb | 6 | ||||
-rw-r--r-- | app/models/repository.rb | 6 |
2 files changed, 4 insertions, 8 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb index f02fe240540..9d721661629 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -172,10 +172,8 @@ class Commit @raw.send(m, *args, &block) end - def respond_to?(method) - return true if @raw.respond_to?(method) - - super + def respond_to_missing?(method, include_private = false) + @raw.respond_to?(method, include_private) || super end # Truncate sha to 8 characters diff --git a/app/models/repository.rb b/app/models/repository.rb index 1ca97017637..2c6347222aa 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -163,10 +163,8 @@ class Repository end end - def respond_to?(method) - return true if raw_repository.respond_to?(method) - - super + def respond_to_missing?(method, include_private = false) + raw_repository.respond_to?(method, include_private) || super end def blob_at(sha, path) |