Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'config/initializers/sawyer_patch.rb')
-rw-r--r--config/initializers/sawyer_patch.rb48
1 files changed, 11 insertions, 37 deletions
diff --git a/config/initializers/sawyer_patch.rb b/config/initializers/sawyer_patch.rb
index 34d2843d165..2a946cf0f7d 100644
--- a/config/initializers/sawyer_patch.rb
+++ b/config/initializers/sawyer_patch.rb
@@ -6,47 +6,21 @@ module SawyerClassPatch
def attr_accessor(*attrs)
attrs.each do |attribute|
class_eval do
- # rubocop:disable Gitlab/ModuleWithInstanceVariables
- if method_defined?(attribute) || method_defined?("#{attribute}=") || method_defined?("#{attribute}?")
- define_method attribute do
- raise Sawyer::Error,
- "Sawyer method \"#{attribute}\" overlaps Ruby method. Convert to a hash to access the attribute."
- end
-
- define_method "#{attribute}=" do |value|
- raise Sawyer::Error,
- "Sawyer method \"#{attribute}\" overlaps Ruby method. Convert to a hash to access the attribute."
- end
-
- define_method "#{attribute}?" do
- raise Sawyer::Error,
- "Sawyer method \"#{attribute}\" overlaps Ruby method. Convert to a hash to access the attribute."
- end
- else
- define_method attribute do
- Gitlab::Import::Logger.warn(
- Gitlab::ApplicationContext.current.merge(
- {
- message: 'Sawyer attribute called',
- attribute: attribute,
- caller: Gitlab::BacktraceCleaner.clean_backtrace(caller)
- }
- )
- )
-
- @attrs[attribute.to_sym]
- end
+ define_method attribute do
+ raise Sawyer::Error,
+ "Sawyer method \"#{attribute}\" access is forbidden. Convert to a hash to access the attribute."
+ end
- define_method "#{attribute}=" do |value|
- @attrs[attribute.to_sym] = value
- end
+ define_method "#{attribute}=" do |value|
+ raise Sawyer::Error,
+ "Sawyer method \"#{attribute}=\" access is forbidden. Convert to a hash to access the attribute."
+ end
- define_method "#{attribute}?" do
- !!@attrs[attribute.to_sym]
- end
+ define_method "#{attribute}?" do
+ raise Sawyer::Error,
+ "Sawyer method \"#{attribute}?\" overlaps Ruby method. Convert to a hash to access the attribute."
end
end
- # rubocop:enable Gitlab/ModuleWithInstanceVariables
end
end
end