Class: Offroad::MirrorInfo

Inherits:
ActiveRecord::Base show all
Defined in:
lib/app/models/offroad/mirror_info.rb

Overview

Non-database model representing general information attached to any mirror file Based on the pattern found here: stackoverflow.com/questions/315850/rails-model-without-database

Constant Summary

Constants included from ModelExtensions

Offroad::ModelExtensions::OFFROAD_GROUP_MODES, Offroad::ModelExtensions::OFFROAD_VALID_MODES

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ModelExtensions

#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

.columnsObject



9
10
11
# File 'lib/app/models/offroad/mirror_info.rb', line 9

def self.columns
  @columns ||= []
end

.new_from_group(group, initial_file = false) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/app/models/offroad/mirror_info.rb', line 32

def self.new_from_group(group, initial_file = false)
  mode = Offroad::app_online? ? "online" : "offline"
  migration_query = "SELECT version FROM schema_migrations ORDER BY version"
  migrations = Offroad::group_base_model.connection.select_all(migration_query).map{ |r| r["version"] }
  return MirrorInfo.new(
    :created_at => Time.now.to_s,
    :online_site => Offroad::online_url,
    :app => Offroad::app_name,
    :app_mode => mode.titleize,
    :app_version => Offroad::app_version,
    :operating_system => RUBY_PLATFORM,
    :generator => "Offroad " + Offroad::VERSION,
    :schema_migrations => migrations.join(","),
    :initial_file => initial_file
  )
end

.safe_to_load_from_cargo_stream?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/app/models/offroad/mirror_info.rb', line 28

def self.safe_to_load_from_cargo_stream?
  true
end

Instance Method Details

#saveObject

Raises:



49
50
51
# File 'lib/app/models/offroad/mirror_info.rb', line 49

def save
  raise DataError.new("Cannot save MirrorInfo records")
end