Class: ZimbraInterceptingProxy::User

Inherits:
Object
  • Object
show all
Defined in:
lib/zimbra_intercepting_proxy/user.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user_identifier) ⇒ User

user_identifier can be an email address, zimbraId UUID or just the local part of an email address, like user in [email protected]



8
9
10
11
12
# File 'lib/zimbra_intercepting_proxy/user.rb', line 8

def initialize(user_identifier)
  @zimbraId = set_zimbraId user_identifier
  @email = set_email user_identifier
  User.load_migrated_users
end

Instance Attribute Details

#emailObject

Returns the value of attribute email.



4
5
6
# File 'lib/zimbra_intercepting_proxy/user.rb', line 4

def email
  @email
end

#zimbraIdObject

Returns the value of attribute zimbraId.



4
5
6
# File 'lib/zimbra_intercepting_proxy/user.rb', line 4

def zimbraId
  @zimbraId
end

Class Method Details

.DBObject



41
42
43
# File 'lib/zimbra_intercepting_proxy/user.rb', line 41

def self.DB
  load_migrated_users
end

.load_migrated_usersObject



37
38
39
# File 'lib/zimbra_intercepting_proxy/user.rb', line 37

def self.load_migrated_users
  YAML.load_file ZimbraInterceptingProxy::Config.migrated_users_file
end

Instance Method Details

#backendObject



19
20
21
22
# File 'lib/zimbra_intercepting_proxy/user.rb', line 19

def backend
  return ZimbraInterceptingProxy::Config.new_backend if migrated?
  ZimbraInterceptingProxy::Config.old_backend
end

#find_in_dbObject



24
25
26
27
# File 'lib/zimbra_intercepting_proxy/user.rb', line 24

def find_in_db
  return User.DB[email] if has_email?
  return User.DB.invert[zimbraId] if has_zimbraId?
end

#has_email?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/zimbra_intercepting_proxy/user.rb', line 29

def has_email?
  !email.nil?
end

#has_zimbraId?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/zimbra_intercepting_proxy/user.rb', line 33

def has_zimbraId?
  !zimbraId.nil?
end

#migrated?Boolean

If user has email (unless email.nil?)

Returns:

  • (Boolean)


15
16
17
# File 'lib/zimbra_intercepting_proxy/user.rb', line 15

def migrated?
  !find_in_db.nil?
end