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/note_text.rb,
lib/gitlab/github_import/representation/lfs_object.rb,
lib/gitlab/github_import/representation/issue_event.rb,
lib/gitlab/github_import/representation/collaborator.rb,
lib/gitlab/github_import/representation/pull_request.rb,
lib/gitlab/github_import/representation/expose_attribute.rb,
lib/gitlab/github_import/representation/protected_branch.rb,
lib/gitlab/github_import/representation/pull_request_review.rb,
lib/gitlab/github_import/representation/diff_notes/discussion_id.rb,
lib/gitlab/github_import/representation/pull_requests/review_requests.rb,
lib/gitlab/github_import/representation/diff_notes/suggestion_formatter.rb

Defined Under Namespace

Modules: DiffNotes, ExposeAttribute, PullRequests, ToHash Classes: Collaborator, DiffNote, Issue, IssueEvent, LfsObject, Note, NoteText, ProtectedBranch, PullRequest, PullRequestReview, 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