Class: RedisImporter::RedisImporter
- Inherits:
-
Object
- Object
- RedisImporter::RedisImporter
- Includes:
- GemConfigurator
- Defined in:
- lib/redis_importer/redis_importer.rb
Instance Attribute Summary collapse
-
#collection ⇒ Object
Returns the value of attribute collection.
-
#commands ⇒ Object
readonly
Returns the value of attribute commands.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#files ⇒ Object
readonly
Returns the value of attribute files.
Instance Method Summary collapse
-
#import ⇒ Object
Converts each csv file in the collection to objects, which are then saved into the redis store.
-
#initialize ⇒ RedisImporter
constructor
Instantiates and configures a RedisImporter object.
Constructor Details
#initialize ⇒ RedisImporter
Instantiates and configures a RedisImporter object
9 10 11 12 13 14 15 |
# File 'lib/redis_importer/redis_importer.rb', line 9 def initialize configure self.collection = Object::const_get("#{@settings['storage_method'].camelcase}Collection").new() self.files = self.collection.files self.commands = [] end |
Instance Attribute Details
#collection ⇒ Object
Returns the value of attribute collection.
6 7 8 |
# File 'lib/redis_importer/redis_importer.rb', line 6 def collection @collection end |
#commands ⇒ Object
Returns the value of attribute commands.
5 6 7 |
# File 'lib/redis_importer/redis_importer.rb', line 5 def commands @commands end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
5 6 7 |
# File 'lib/redis_importer/redis_importer.rb', line 5 def errors @errors end |
#files ⇒ Object
Returns the value of attribute files.
5 6 7 |
# File 'lib/redis_importer/redis_importer.rb', line 5 def files @files end |
Instance Method Details
#import ⇒ Object
Converts each csv file in the collection to objects, which are then saved into the redis store.
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/redis_importer/redis_importer.rb', line 18 def import files.each do |file| begin convert_to_redis_commands(file) if class_exists?(file.to_class_name.to_sym) rescue NoMethodError add_errors($!) rescue NameError add_errors("#{file.name} is not matched by a class #{file.to_class_name} in the system.") end end pipeline end |