Class: ExtraLoop::Storage::DatasetFactory
- Inherits:
-
Object
- Object
- ExtraLoop::Storage::DatasetFactory
- Defined in:
- lib/extraloop/redis-storage/dataset_factory.rb
Overview
Creates a simple class to store an ExtraLoop generated dataset using Ohm
Instance Method Summary collapse
- #get_class ⇒ Object
-
#initialize(classname, attributes = []) ⇒ DatasetFactory
constructor
A new instance of DatasetFactory.
Constructor Details
#initialize(classname, attributes = []) ⇒ DatasetFactory
Returns a new instance of DatasetFactory.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/extraloop/redis-storage/dataset_factory.rb', line 5 def initialize(classname, attributes=[]) @classname = (classname.to_s.split "").each_with_index.map { |char, index| index == 0 && char.upcase or char }.join return Object.const_get @classname if Object.const_defined? @classname Object.const_set(@classname, Class.new(ExtraLoop::Storage::Record) { attributes.each { |attr| attribute attr } }) end |
Instance Method Details
#get_class ⇒ Object
16 17 18 |
# File 'lib/extraloop/redis-storage/dataset_factory.rb', line 16 def get_class Object.const_get(@classname) end |