diff options
author | Rémy Coutable <remy@rymai.me> | 2017-01-24 17:07:56 +0100 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-01-25 12:14:02 +0100 |
commit | 68e94450a06e043ecf58ede565060f41b61043f9 (patch) | |
tree | 30ce6ad74036b92e000aee5ef0a71a7dfb8526f1 /lib | |
parent | 0ac65b6cc31962c293782a1f3e8d6d41922569c8 (diff) | |
download | gitlab-ce-68e94450a06e043ecf58ede565060f41b61043f9.tar.gz |
Raise Gitlab::View::Presenter::CannotOverrideMethodError if presentee already respond to method26943-fix-user-in-build-presenter
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/view/presenter/base.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/view/presenter/delegated.rb | 6 |
2 files changed, 6 insertions, 2 deletions
diff --git a/lib/gitlab/view/presenter/base.rb b/lib/gitlab/view/presenter/base.rb index 83c8ba5c1cf..dbfe0941e4d 100644 --- a/lib/gitlab/view/presenter/base.rb +++ b/lib/gitlab/view/presenter/base.rb @@ -1,6 +1,8 @@ module Gitlab module View module Presenter + CannotOverrideMethodError = Class.new(StandardError) + module Base extend ActiveSupport::Concern diff --git a/lib/gitlab/view/presenter/delegated.rb b/lib/gitlab/view/presenter/delegated.rb index fd90f7c2bad..387ff0f5d43 100644 --- a/lib/gitlab/view/presenter/delegated.rb +++ b/lib/gitlab/view/presenter/delegated.rb @@ -8,9 +8,11 @@ module Gitlab @subject = subject attributes.each do |key, value| - unless subject.respond_to?(key) - define_singleton_method(key) { value } + if subject.respond_to?(key) + raise CannotOverrideMethodError.new("#{subject} already respond to #{key}!") end + + define_singleton_method(key) { value } end super(subject) |