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:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-07-09 00:06:02 +0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-07-09 00:06:02 +0300
commit8f3b6591ccc1dcebb0e4ae1e3cf44588b2a4afe8 (patch)
treeb470d8784d2e8e13b14a16aa9450a3676d520c33 /lib/gitlab/import/github/mapper/base.rb
parentcb8e9bb6bb0cb3712b888f79d2e8e324724742ad (diff)
Extract base mappergh-refactor
Diffstat (limited to 'lib/gitlab/import/github/mapper/base.rb')
-rw-r--r--lib/gitlab/import/github/mapper/base.rb37
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/gitlab/import/github/mapper/base.rb b/lib/gitlab/import/github/mapper/base.rb
new file mode 100644
index 00000000000..78e8b97eb03
--- /dev/null
+++ b/lib/gitlab/import/github/mapper/base.rb
@@ -0,0 +1,37 @@
+module Gitlab
+ module Import
+ module Github
+ module Mapper
+ class Base
+ def initialize(project, client)
+ @project = project
+ @client = client
+ end
+
+ def each
+ return enum_for(:each) unless block_given?
+
+ method = klass.to_s.underscore.pluralize
+
+ client.public_send(method).each do |raw|
+ yield(klass.new(attributes_for(raw)))
+ end
+ end
+
+ private
+
+ attr_reader :project, :client
+
+ def attributes_for
+ {}
+ end
+
+ def klass
+ raise NotImplementedError,
+ "#{self.class} does not implement #{__method__}"
+ end
+ end
+ end
+ end
+ end
+end