Commit d626d089 by Ivan Lan

Merge branch 'lan/fix_file_loading_bug' into 'master'

Lan/fix file loading bug See merge request !5
parents 8c11eb17 88dfe1bc
...@@ -5,10 +5,10 @@ module WeatherModel ...@@ -5,10 +5,10 @@ module WeatherModel
require 'factory_girl_rails' require 'factory_girl_rails'
def self.included base def self.included base
WeatherModel::SourceSchema.sorts.each { |sort| Object.const_set(sort, Module.new)} ::WeatherModel::SourceSchema.sorts.each { |sort| ::WeatherModel.const_set(sort, Module.new)}
WeatherModel::SourceSchema.constants.each do |source| ::WeatherModel::SourceSchema.constants.each do |source|
settings = SourceSchema.const_get(source) settings = ::WeatherModel::SourceSchema.const_get(source)
Object.const_get(settings[:sort]).const_set("#{source.to_s.gsub('_', '::')}", Class.new(Storer::Mysql)).use_settings(settings) ::WeatherModel.const_get(settings[:sort]).const_set(source, Class.new(Storer::Mysql)).use_settings(settings)
end end
end end
......
...@@ -5,9 +5,9 @@ module WeatherModel ...@@ -5,9 +5,9 @@ module WeatherModel
[:Forecast, :AutoStation, :Aqi] [:Forecast, :AutoStation, :Aqi]
end end
Dir[File.join(File.dirname(__FILE__), 'source_schemas/*.rb')].each { |file|
require file
}
end end
end end
Dir['./lib/weather-model/source_schemas/*.rb'].each { |file|
require file
}
\ No newline at end of file
module WeatherModel module WeatherModel
module SourceSchema module SourceSchema
Forecast = AqiForecast =
{ {
sort: 'Aqi', sort: 'Aqi',
table_name: :aqi_forecasts, table_name: :aqi_forecasts,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment