Class: Socialcast::CommandLine::ProvisionPhoto

Inherits:
Object
  • Object
show all
Includes:
Provisioner
Defined in:
lib/socialcast/command_line/provision_photo.rb

Constant Summary collapse

MAX_BATCH_SIZE =
50

Constants included from Provisioner

Socialcast::CommandLine::Provisioner::DEFAULT_OUTPUT_FILE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Provisioner

#initialize

Instance Attribute Details

#usersObject

Returns the value of attribute users.



5
6
7
# File 'lib/socialcast/command_line/provision_photo.rb', line 5

def users
  @users
end

Instance Method Details

#syncObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/socialcast/command_line/provision_photo.rb', line 8

def sync
  @ldap_config['connections'].keys.each do |connection_name|
    LDAPConnector.attribute_mappings_for(connection_name, @ldap_config).fetch(LDAPConnector::PROFILE_PHOTO_ATTRIBUTE)
  end

  init_users

  each_ldap_connector do |connector|
    connector.each_photo_hash do |photo_hash|
      email = photo_hash[LDAPConnector::EMAIL_ATTRIBUTE]
      users[email] = photo_hash[LDAPConnector::PROFILE_PHOTO_ATTRIBUTE]
      handle_batch if users.size >= MAX_BATCH_SIZE
    end
  end

  handle_batch if users.any?
end