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.



34
35
36
37
38
39
40
# File 'lib/commands/init/user_model.rb', line 34

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.



32
33
34
# File 'lib/commands/init/user_model.rb', line 32

def 
  @login
end

#passwordObject

Returns the value of attribute password.



32
33
34
# File 'lib/commands/init/user_model.rb', line 32

def password
  @password
end

Class Method Details

.abstractObject

Internal implementation - don’t mess with this



28
29
30
# File 'lib/commands/init/user_model.rb', line 28

def self.abstract
  true
end

Instance Method Details

#emailObject



42
43
44
# File 'lib/commands/init/user_model.rb', line 42

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

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



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/commands/init/user_model.rb', line 67

def execute(p4, models=nil, super_user=nil)
  return if self.class.skip

  puts "user: #{to_spec} as #{p4.user}"

  p4.save_user(to_spec, '-f')

  p4.user = 
  p4.password = '' if password

  p4.run_password('', password) if password

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

#full_nameObject



46
47
48
# File 'lib/commands/init/user_model.rb', line 46

def full_name
  @full_name || 
end

#super?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/commands/init/user_model.rb', line 50

def super?
  @super
end

#to_sObject



54
55
56
# File 'lib/commands/init/user_model.rb', line 54

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

#to_specObject



58
59
60
61
62
63
64
65
# File 'lib/commands/init/user_model.rb', line 58

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