Module: Gitlab::GithubImport::Representation

Defined in:
lib/gitlab/github_import/representation.rb,
lib/gitlab/github_import/representation/note.rb,
lib/gitlab/github_import/representation/user.rb,
lib/gitlab/github_import/representation/issue.rb,
lib/gitlab/github_import/representation/to_hash.rb,
lib/gitlab/github_import/representation/diff_note.rb,
lib/gitlab/github_import/representation/lfs_object.rb,
lib/gitlab/github_import/representation/pull_request.rb,
lib/gitlab/github_import/representation/expose_attribute.rb

Defined Under Namespace

Modules: ExposeAttribute, ToHash Classes: DiffNote, Issue, LfsObject, Note, PullRequest, User

Constant Summary collapse

TIMESTAMP_KEYS =
%i[created_at updated_at merged_at].freeze

Class Method Summary collapse

Class Method Details

.symbolize_hash(raw_hash = nil) ⇒ Object

Converts a Hash with String based keys to one that can be used by the various Representation classes.

Example:

Representation.symbolize_hash('number' => 10) # => { number: 10 }

14
15
16
17
18
19
20
21
22
# File 'lib/gitlab/github_import/representation.rb', line 14

def self.symbolize_hash(raw_hash = nil)
  hash = raw_hash.deep_symbolize_keys

  TIMESTAMP_KEYS.each do |key|
    hash[key] = Time.parse(hash[key]) if hash[key].is_a?(String)
  end

  hash
end