Class: ZimbraWall::User

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

Constant Summary collapse

@@db =
{}

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]



10
11
12
13
14
# File 'lib/zimbra_wall/user.rb', line 10

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_wall/user.rb', line 4

def email
  @email
end

#zimbraIdObject

Returns the value of attribute zimbraId.



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

def zimbraId
  @zimbraId
end

Class Method Details

.DBObject



46
47
48
49
# File 'lib/zimbra_wall/user.rb', line 46

def self.DB
  load_migrated_users
  @@db
end

.load_migrated_usersObject

Return the old DB if the YAML file has error



40
41
42
43
44
# File 'lib/zimbra_wall/user.rb', line 40

def self.load_migrated_users
  data = ZimbraWall::Yamler.db
  return @@db unless data
  @@db = data
end

Instance Method Details

#backendObject



21
22
23
# File 'lib/zimbra_wall/user.rb', line 21

def backend
  ZimbraWall::Config.backend
end

#blocked?Boolean

If user has email (unless email.nil?)

Returns:

  • (Boolean)


17
18
19
# File 'lib/zimbra_wall/user.rb', line 17

def blocked?
  !find_in_db.nil?
end

#find_in_dbObject



25
26
27
28
29
# File 'lib/zimbra_wall/user.rb', line 25

def find_in_db
  self.zimbraId = User.DB[email] if has_email?
  self.email = User.DB.invert[zimbraId] if has_zimbraId?
  User.DB[email] || User.DB.invert[zimbraId]
end

#has_email?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/zimbra_wall/user.rb', line 31

def has_email?
  !email.nil?
end

#has_zimbraId?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/zimbra_wall/user.rb', line 35

def has_zimbraId?
  !zimbraId.nil?
end