Commit a003b3f8 by ivan Lan

Fix the bug of require file for source_schema

parent 8c11eb17
......@@ -5,10 +5,10 @@ module WeatherModel
require 'factory_girl_rails'
def self.included base
WeatherModel::SourceSchema.sorts.each { |sort| Object.const_set(sort, Module.new)}
WeatherModel::SourceSchema.constants.each do |source|
settings = SourceSchema.const_get(source)
Object.const_get(settings[:sort]).const_set("#{source.to_s.gsub('_', '::')}", Class.new(Storer::Mysql)).use_settings(settings)
::WeatherModel::SourceSchema.sorts.each { |sort| ::WeatherModel.const_set(sort, Module.new)}
::WeatherModel::SourceSchema.constants.each do |source|
settings = ::WeatherModel::SourceSchema.const_get(source)
::WeatherModel.const_get(settings[:sort]).const_set(source, Class.new(Storer::Mysql)).use_settings(settings)
end
end
......
module WeatherModel
module SourceSchema
def self.sorts
[:Forecast, :AutoStation, :Aqi]
end
Dir[File.join(File.dirname(__FILE__), 'source_schemas/*.rb')].each { |file|
require file
}
end
end
Dir['./lib/weather-model/source_schemas/*.rb'].each { |file|
require file
}
\ No newline at end of file
module WeatherModel
module SourceSchema
Forecast =
AqiForecast =
{
sort: 'Aqi',
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