Class: Gitlab::GithubImport::Representation::User

Inherits:
Object
  • Object
show all
Includes:
Representable
Defined in:
lib/gitlab/github_import/representation/user.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ User

attributes - A Hash containing the user details. The keys of this Hash (and any nested hashes) must be symbols.



28
29
30
# File 'lib/gitlab/github_import/representation/user.rb', line 28

def initialize(attributes)
  @attributes = attributes
end

Class Method Details

.from_api_response(user, additional_data = {}) ⇒ Object

Builds a user from a GitHub API response.

user - An instance of Hash containing the user details.



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

def self.from_api_response(user, additional_data = {})
  new(
    id: user[:id],
    login: user[:login]
  )
end

.from_json_hash(raw_hash) ⇒ Object

Builds a user using a Hash that was built from a JSON payload.



22
23
24
# File 'lib/gitlab/github_import/representation/user.rb', line 22

def self.from_json_hash(raw_hash)
  new(Representation.symbolize_hash(raw_hash))
end