Class: ZimbraInterceptingProxy::User
- Inherits:
-
Object
- Object
- ZimbraInterceptingProxy::User
- Defined in:
- lib/zimbra_intercepting_proxy/user.rb
Constant Summary collapse
- @@db =
{}
Instance Attribute Summary collapse
-
#email ⇒ Object
Returns the value of attribute email.
-
#zimbraId ⇒ Object
Returns the value of attribute zimbraId.
Class Method Summary collapse
- .DB ⇒ Object
-
.load_migrated_users ⇒ Object
Return the old DB if the YAML file has error.
Instance Method Summary collapse
- #backend ⇒ Object
- #find_in_db ⇒ Object
- #has_email? ⇒ Boolean
- #has_zimbraId? ⇒ Boolean
-
#initialize(user_identifier) ⇒ User
constructor
user_identifier can be an email address, zimbraId UUID or just the local part of an email address, like user in [email protected].
-
#migrated? ⇒ Boolean
If user has email (unless email.nil?).
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_intercepting_proxy/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
#email ⇒ Object
Returns the value of attribute email.
4 5 6 |
# File 'lib/zimbra_intercepting_proxy/user.rb', line 4 def email @email end |
#zimbraId ⇒ Object
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
.DB ⇒ Object
46 47 48 49 |
# File 'lib/zimbra_intercepting_proxy/user.rb', line 46 def self.DB load_migrated_users @@db end |
.load_migrated_users ⇒ Object
Return the old DB if the YAML file has error
40 41 42 43 44 |
# File 'lib/zimbra_intercepting_proxy/user.rb', line 40 def self.load_migrated_users data = ZimbraInterceptingProxy::Yamler.db return @@db unless data @@db = data end |
Instance Method Details
#backend ⇒ Object
21 22 23 24 |
# File 'lib/zimbra_intercepting_proxy/user.rb', line 21 def backend return ZimbraInterceptingProxy::Config.new_backend if migrated? ZimbraInterceptingProxy::Config.old_backend end |
#find_in_db ⇒ Object
26 27 28 29 |
# File 'lib/zimbra_intercepting_proxy/user.rb', line 26 def find_in_db return User.DB[email] if has_email? return User.DB.invert[zimbraId] if has_zimbraId? end |
#has_email? ⇒ Boolean
31 32 33 |
# File 'lib/zimbra_intercepting_proxy/user.rb', line 31 def has_email? !email.nil? end |
#has_zimbraId? ⇒ Boolean
35 36 37 |
# File 'lib/zimbra_intercepting_proxy/user.rb', line 35 def has_zimbraId? !zimbraId.nil? end |
#migrated? ⇒ Boolean
If user has email (unless email.nil?)
17 18 19 |
# File 'lib/zimbra_intercepting_proxy/user.rb', line 17 def migrated? !find_in_db.nil? end |