module INE::Places

Constants

ROOT
Version

Public Class Methods

hydratate(klass, data_path, options) click to toggle source
# File lib/ine.rb, line 37
def self.hydratate(klass, data_path, options)
  data = CSV.read(open(data_path), headers: true)

  data.each do |row|
    if obj = klass.find(row[options[:id_column]])
      value = row[options[:value_column]]
      case options[:convert_to]
      when :float
        value = value.to_f
      when :integer, :int
        value = value.to_i
      end

      obj.data.send((options[:as].to_s + '=').to_sym, value)
    end
  end

  nil
end
preload() click to toggle source
# File lib/ine.rb, line 29
def self.preload
  AutonomousRegionsCollection.records
  ProvincesCollection.records
  PlacesCollection.records

  nil
end