summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2017-02-22 11:51:46 -0600
committerDouwe Maan <douwe@selenight.nl>2017-02-23 09:32:42 -0600
commit75f5fa997de148c9bc0e5bd6e6f6050526a0b164 (patch)
treee2fd6db5b1190817c062a8df20018dd00be68ce0 /lib
parent7d4b52b27dcbe30d85d4fad27e983cee51cf6677 (diff)
downloadgitlab-ce-75f5fa997de148c9bc0e5bd6e6f6050526a0b164.tar.gz
Enable Rails/Delegate
Diffstat (limited to 'lib')
-rw-r--r--lib/bitbucket/connection.rb4
-rw-r--r--lib/gitlab/access.rb4
-rw-r--r--lib/gitlab/ci/build/artifacts/metadata/entry.rb4
-rw-r--r--lib/gitlab/current_settings.rb4
-rw-r--r--lib/gitlab/git/commit.rb4
-rw-r--r--lib/gitlab/git/repository.rb14
-rw-r--r--lib/gitlab/github_import/issuable_formatter.rb4
-rw-r--r--lib/gitlab/ldap/person.rb4
-rw-r--r--lib/gitlab/redis.rb8
-rw-r--r--lib/gitlab/visibility_level.rb4
10 files changed, 14 insertions, 40 deletions
diff --git a/lib/bitbucket/connection.rb b/lib/bitbucket/connection.rb
index 287410bf46f..b9279c33f5b 100644
--- a/lib/bitbucket/connection.rb
+++ b/lib/bitbucket/connection.rb
@@ -24,9 +24,7 @@ module Bitbucket
response.parsed
end
- def expired?
- connection.expired?
- end
+ delegate :expired?, to: :connection
def refresh!
response = connection.refresh!
diff --git a/lib/gitlab/access.rb b/lib/gitlab/access.rb
index 9b484a2ecfd..3b210eeda9d 100644
--- a/lib/gitlab/access.rb
+++ b/lib/gitlab/access.rb
@@ -21,9 +21,7 @@ module Gitlab
PROTECTION_DEV_CAN_MERGE = 3
class << self
- def values
- options.values
- end
+ delegate :values, to: :options
def all_values
options_with_owner.values
diff --git a/lib/gitlab/ci/build/artifacts/metadata/entry.rb b/lib/gitlab/ci/build/artifacts/metadata/entry.rb
index 7f4c750b6fd..c1d4d541efb 100644
--- a/lib/gitlab/ci/build/artifacts/metadata/entry.rb
+++ b/lib/gitlab/ci/build/artifacts/metadata/entry.rb
@@ -91,9 +91,7 @@ module Gitlab
blank_node? || @entries.include?(@path)
end
- def empty?
- children.empty?
- end
+ delegate :empty?, to: :children
def total_size
descendant_pattern = %r{^#{Regexp.escape(@path)}}
diff --git a/lib/gitlab/current_settings.rb b/lib/gitlab/current_settings.rb
index e20f5f6f514..82576d197fe 100644
--- a/lib/gitlab/current_settings.rb
+++ b/lib/gitlab/current_settings.rb
@@ -25,9 +25,7 @@ module Gitlab
settings || in_memory_application_settings
end
- def sidekiq_throttling_enabled?
- current_application_settings.sidekiq_throttling_enabled?
- end
+ delegate :sidekiq_throttling_enabled?, to: :current_application_settings
def in_memory_application_settings
@in_memory_application_settings ||= ::ApplicationSetting.new(::ApplicationSetting.defaults)
diff --git a/lib/gitlab/git/commit.rb b/lib/gitlab/git/commit.rb
index d785516ebdd..fd2b26c4a63 100644
--- a/lib/gitlab/git/commit.rb
+++ b/lib/gitlab/git/commit.rb
@@ -218,9 +218,7 @@ module Gitlab
raw_commit.parents.map { |c| Gitlab::Git::Commit.new(c) }
end
- def tree
- raw_commit.tree
- end
+ delegate :tree, to: :raw_commit
def stats
Gitlab::Git::CommitStats.new(self)
diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb
index 7068e68a855..e1fabff4e29 100644
--- a/lib/gitlab/git/repository.rb
+++ b/lib/gitlab/git/repository.rb
@@ -162,13 +162,9 @@ module Gitlab
!empty?
end
- def empty?
- rugged.empty?
- end
-
- def bare?
- rugged.bare?
- end
+ delegate :empty?,
+ :bare?,
+ to: :rugged
def repo_exists?
!!rugged
@@ -565,9 +561,7 @@ module Gitlab
# will trigger a +:mixed+ reset and the working directory will be
# replaced with the content of the index. (Untracked and ignored files
# will be left alone)
- def reset(ref, reset_type)
- rugged.reset(ref, reset_type)
- end
+ delegate :reset, to: :rugged
# Mimic the `git clean` command and recursively delete untracked files.
# Valid keys that can be passed in the +options+ hash are:
diff --git a/lib/gitlab/github_import/issuable_formatter.rb b/lib/gitlab/github_import/issuable_formatter.rb
index 29fb0f9d333..27b171d6ddb 100644
--- a/lib/gitlab/github_import/issuable_formatter.rb
+++ b/lib/gitlab/github_import/issuable_formatter.rb
@@ -7,9 +7,7 @@ module Gitlab
raise NotImplementedError
end
- def number
- raw_data.number
- end
+ delegate :number, to: :raw_data
def find_condition
{ iid: number }
diff --git a/lib/gitlab/ldap/person.rb b/lib/gitlab/ldap/person.rb
index 7084fd1767d..43eb73250b7 100644
--- a/lib/gitlab/ldap/person.rb
+++ b/lib/gitlab/ldap/person.rb
@@ -43,9 +43,7 @@ module Gitlab
attribute_value(:email)
end
- def dn
- entry.dn
- end
+ delegate :dn, to: :entry
private
diff --git a/lib/gitlab/redis.rb b/lib/gitlab/redis.rb
index 53665c8375e..e9c07095042 100644
--- a/lib/gitlab/redis.rb
+++ b/lib/gitlab/redis.rb
@@ -13,15 +13,11 @@ module Gitlab
class << self
# Do NOT cache in an instance variable. Result may be mutated by caller.
- def params
- new.params
- end
+ delegate :params, to: :new
# Do NOT cache in an instance variable. Result may be mutated by caller.
# @deprecated Use .params instead to get sentinel support
- def url
- new.url
- end
+ delegate :url, to: :new
def with
@pool ||= ConnectionPool.new(size: pool_size) { ::Redis.new(params) }
diff --git a/lib/gitlab/visibility_level.rb b/lib/gitlab/visibility_level.rb
index a4e966e4016..b28708c34e1 100644
--- a/lib/gitlab/visibility_level.rb
+++ b/lib/gitlab/visibility_level.rb
@@ -33,9 +33,7 @@ module Gitlab
PUBLIC = 20 unless const_defined?(:PUBLIC)
class << self
- def values
- options.values
- end
+ delegate :values, to: :options
def options
{