Class: Commands::Init::UserModel

Inherits:
InitModel show all
Defined in:
lib/commands/init/user_model.rb

Direct Known Subclasses

DefaultSuperUser

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from InitModel

inheritable_attributes, inherited, #rank, run

Constructor Details

#initializeUserModel

Returns a new instance of UserModel.



28
29
30
31
32
33
34
# File 'lib/commands/init/user_model.rb', line 28

def initialize
  @login = self.class.
  @full_name = self.class.full_name
  @password = self.class.password
  @email = self.class.email
  @super = self.class.super
end

Instance Attribute Details

#loginObject

Returns the value of attribute login.



26
27
28
# File 'lib/commands/init/user_model.rb', line 26

def 
  @login
end

#passwordObject

Returns the value of attribute password.



26
27
28
# File 'lib/commands/init/user_model.rb', line 26

def password
  @password
end

Class Method Details

.abstractObject

Internal implementation - don’t mess with this



22
23
24
# File 'lib/commands/init/user_model.rb', line 22

def self.abstract
  true
end

Instance Method Details

#emailObject



36
37
38
# File 'lib/commands/init/user_model.rb', line 36

def email
  @email || "#{}@example.com"
end

#execute(p4, models = nil, super_user = nil) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/commands/init/user_model.rb', line 61

def execute(p4, models=nil, super_user=nil)
  p4.save_user(to_spec, '-f')

  p4.user = 
  p4.password = ''

  p4.run_password('', password) if password

  if super_user
    p4.user = super_user.
    p4.password = super_user.password
  end
end

#full_nameObject



40
41
42
# File 'lib/commands/init/user_model.rb', line 40

def full_name
  @full_name || 
end

#super?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/commands/init/user_model.rb', line 44

def super?
  @super
end

#to_sObject



48
49
50
# File 'lib/commands/init/user_model.rb', line 48

def to_s
  "UserModel: login=#{} email=#{email} full_name=#{full_name} password=#{password}"
end

#to_specObject



52
53
54
55
56
57
58
59
# File 'lib/commands/init/user_model.rb', line 52

def to_spec
  spec = {
      'User' => ,
      'Email' => email,
      'FullName' => full_name
  }
  spec
end