Class: Offroad::GroupState
Constant Summary
ModelExtensions::OFFROAD_GROUP_MODES, ModelExtensions::OFFROAD_VALID_MODES
Class Method Summary
collapse
Instance Method Summary
collapse
#acts_as_offroadable, #acts_as_offroadable?, #offroad_global_data?, #offroad_group_base?, #offroad_group_data?, #offroad_model_state, #safe_to_load_from_cargo_stream?
Class Method Details
.note_group_destroyed(group) ⇒ Object
74
75
76
77
|
# File 'lib/app/models/offroad/group_state.rb', line 74
def self.note_group_destroyed(group)
rec = find_by_app_group_id(group.id)
rec.destroy
end
|
.safe_to_load_from_cargo_stream? ⇒ Boolean
70
71
72
|
# File 'lib/app/models/offroad/group_state.rb', line 70
def self.safe_to_load_from_cargo_stream?
true
end
|
Instance Method Details
#app_group ⇒ Object
13
14
15
|
# File 'lib/app/models/offroad/group_state.rb', line 13
def app_group
Offroad::group_base_model.find_by_id(app_group_id)
end
|
#before_create ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/app/models/offroad/group_state.rb', line 23
def before_create
if Offroad::app_offline?
self.operating_system ||= RUBY_PLATFORM
end
self.confirmed_group_data_version ||= 1
self.confirmed_global_data_version ||= Offroad::app_online? ? SystemState::current_mirror_version : 1
end
|
#update_from_remote_group_state!(remote_gs) ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/app/models/offroad/group_state.rb', line 36
def update_from_remote_group_state!(remote_gs)
versioning_columns = [
'confirmed_global_data_version',
'confirmed_group_data_version'
]
online_owned_columns = [
'last_installer_downloaded_at',
'last_down_mirror_created_at',
'last_up_mirror_loaded_at'
]
offline_owned_columns = [
'last_installation_at',
'last_down_mirror_loaded_at',
'last_up_mirror_created_at',
'launcher_version',
'app_version',
'operating_system'
]
(Offroad::app_offline? ? online_owned_columns : offline_owned_columns).each do |col|
self.send("#{col}=", remote_gs.send(col))
end
versioning_columns.each do |col|
self.send("#{col}=", [self.send(col), remote_gs.send(col)].max)
end
save!
end
|
#validate ⇒ Object
9
10
11
|
# File 'lib/app/models/offroad/group_state.rb', line 9
def validate
errors.add_to_base "Cannot find associated app group record" unless app_group
end
|