Class: Users
- Inherits:
-
Entities
- Object
- Entities
- Users
- Defined in:
- lib/africompta/entities/users.rb
Instance Method Summary collapse
- #create(name, full = nil, pass = nil) ⇒ Object
- #init ⇒ Object
- #load ⇒ Object
- #migration_1(u) ⇒ Object
- #setup_data ⇒ Object
Instance Method Details
#create(name, full = nil, pass = nil) ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/africompta/entities/users.rb', line 38 def create(name, full = nil, pass = nil) if not full or not pass dputs(2) { "Creating with hash: #{name.inspect}" } name, full, pass = name[:name], name[:full], name[:pass] end new_user = super(:name => name, :full => full, :pass => pass) new_user.account_index, new_user.movement_index = -1, -1 new_user end |
#init ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/africompta/entities/users.rb', line 17 def init user = Users.create('local', Digest::MD5.hexdigest((rand 2**128).to_s).to_s, rand(2 ** 128).to_s) user.account_index, user.movement_index = 0, 0 dputs(1) { "Created local user #{user}" } user end |
#load ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/africompta/entities/users.rb', line 25 def load super if Users.search_by_name('local').count == 0 dputs(0) { 'User init not here' } init end end |
#migration_1(u) ⇒ Object
33 34 35 36 |
# File 'lib/africompta/entities/users.rb', line 33 def migration_1(u) u.account_index ||= -1 u.movement_index ||= -1 end |
#setup_data ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/africompta/entities/users.rb', line 3 def setup_data @default_type = :SQLiteAC @data_field_id = :id value_str :name value_str :full value_str :pass #value_array :accounts # The last account_index that got transmitted value_int :account_index # The last movement_index that got transmitted value_int :movement_index end |