Class: Codeowners::Import::Organization

Inherits:
Object
  • Object
show all
Defined in:
lib/codeowners/import/organization.rb

Instance Method Summary collapse

Constructor Details

#initialize(client, storage) ⇒ Organization

Returns a new instance of Organization.



6
7
8
9
# File 'lib/codeowners/import/organization.rb', line 6

def initialize(client, storage)
  @client = client
  @storage = storage
end

Instance Method Details

#call(org, debug) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/codeowners/import/organization.rb', line 11

def call(org, debug)
  org = client.org(org, debug)
  users = client.org_members(org, debug)
  users = client.users(users, debug)
  teams = client.teams(org, debug)
  memberships = client.team_members(org, teams, debug)

  storage.transaction do |db|
    db[:orgs].upsert(org)
    db[:users].upsert(users)
    db[:teams].upsert(teams)
    db[:memberships].upsert(memberships)
  end
end