lib/data/lu/states.rb in looky-lu-0.0.2 vs lib/data/lu/states.rb in looky-lu-0.0.3

- old
+ new

@@ -1,7 +1,23 @@ module LookyLu class States + def self.insert_data(country_name, object_name) + + states = from_country country_name + begin + class_object = eval(object_name.camelize) + + states.each do |s| + class_object.create(s) + end + rescue => e + raise "Could not find object for #{object_name.camelize}" + end + + end + + def self.from_country(country_name) yml = YAML.load_file(File.dirname(__FILE__) + "/states.yml") if country_name == 'all' \ No newline at end of file