diff options
author | Francisco Javier López <fjlopez@gitlab.com> | 2018-06-06 19:42:18 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2018-06-06 19:42:18 +0300 |
commit | e8f49b4bee8d803953b852685889a2912609ae84 (patch) | |
tree | fdbef6fc26ebc49be27e1553ea980cb734b8ab7d /lib/gitlab/github_import/representation/lfs_object.rb | |
parent | 0dd7563b7c91141f545432e9082906ebb196a38d (diff) |
Support LFS objects when creating a project by import
Diffstat (limited to 'lib/gitlab/github_import/representation/lfs_object.rb')
-rw-r--r-- | lib/gitlab/github_import/representation/lfs_object.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/gitlab/github_import/representation/lfs_object.rb b/lib/gitlab/github_import/representation/lfs_object.rb new file mode 100644 index 00000000000..debe0fa0baf --- /dev/null +++ b/lib/gitlab/github_import/representation/lfs_object.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +module Gitlab + module GithubImport + module Representation + class LfsObject + include ToHash + include ExposeAttribute + + attr_reader :attributes + + expose_attribute :oid, :download_link + + # Builds a lfs_object + def self.from_api_response(lfs_object) + new({ oid: lfs_object[0], download_link: lfs_object[1] }) + end + + # Builds a new lfs_object using a Hash that was built from a JSON payload. + def self.from_json_hash(raw_hash) + new(Representation.symbolize_hash(raw_hash)) + end + + # attributes - A Hash containing the raw lfs_object details. The keys of this + # Hash must be Symbols. + def initialize(attributes) + @attributes = attributes + end + end + end + end +end |