Commit a003b3f8 by ivan Lan

Fix the bug of require file for source_schema

parent 8c11eb17
...@@ -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
......
module WeatherModel module WeatherModel
module SourceSchema module SourceSchema
def self.sorts def self.sorts
[: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