Class: ApplicationBaseRecord

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/application_base_record.rb

Instance Method Summary collapse

Instance Method Details

#destroy_opt!Object



24
25
26
27
28
29
30
31
# File 'app/models/application_base_record.rb', line 24

def destroy_opt!
  set_valid_flg
  set_updated_user
  set_updated_at
  begin
    self.save
  end
end

#save_opt!Object



12
13
14
15
16
17
18
19
20
21
22
# File 'app/models/application_base_record.rb', line 12

def save_opt!
  set_created_user
  set_updated_user
  set_updated_at
  begin
    self.save!
  rescue ActiveRecord::RecordNotUnique
    errors.add :base, 'Could not save because of primary key restriction.'
    false
  end
end

#set_created_userObject



33
34
35
# File 'app/models/application_base_record.rb', line 33

def set_created_user
  raise 'Extend this method'
end

#set_updated_atObject



42
43
44
# File 'app/models/application_base_record.rb', line 42

def set_updated_at
  self.updated_at = Time.now.utc
end

#set_updated_userObject



36
37
38
# File 'app/models/application_base_record.rb', line 36

def set_updated_user
  raise 'Extend this method'
end

#set_updated_user_args(*args) ⇒ Object



39
40
41
# File 'app/models/application_base_record.rb', line 39

def set_updated_user_args(*args)
  raise 'Extend this method'
end

#set_valid_flgObject



45
46
47
# File 'app/models/application_base_record.rb', line 45

def set_valid_flg
  self.valid_flg = true
end

#update_opt(*args) ⇒ Object



4
5
6
7
8
9
10
# File 'app/models/application_base_record.rb', line 4

def update_opt(*args)
  set_updated_user_args(*args)
  set_updated_at
  begin
    update(*args)
  end
end