Sha256: bdee3760f4a2c0d9dc41a47512a9d41bdaddfd9ab9757484f0ee0be7074dc532

Contents?: true

Size: 718 Bytes

Versions: 7

Compression:

Stored size: 718 Bytes

Contents

require 'earth/rail/country_rail_class'
require 'earth/rail/country_rail_traction_class'

RailClass.class_eval do
  data_miner do
    process "Ensure CountryRailClass, and CountryRailTractionClass are populated" do
      CountryRailTractionClass.run_data_miner!
      CountryRailClass.run_data_miner!
    end
    
    process "Derive rail class names from CountryRailClass and CountryRailTractionClass" do
      names = []
      names += CountryRailTractionClass.select("DISTINCT rail_class_name").map(&:rail_class_name)
      names += CountryRailClass.select("DISTINCT rail_class_name").map(&:rail_class_name)
      names.uniq.each do |name|
        RailClass.find_or_create_by_name(name)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
earth-1.2.1 lib/earth/rail/rail_class/data_miner.rb
earth-1.1.2 lib/earth/rail/rail_class/data_miner.rb
earth-1.1.1 lib/earth/rail/rail_class/data_miner.rb
earth-1.1.0 lib/earth/rail/rail_class/data_miner.rb
earth-1.0.3 lib/earth/rail/rail_class/data_miner.rb
earth-1.0.2 lib/earth/rail/rail_class/data_miner.rb
earth-1.0.1 lib/earth/rail/rail_class/data_miner.rb