Abstract Factory adapter class, if you have a factory type setup, you can easily create an adaptor to make it work with Pickle.
The factory adaptor must have a factories class method that returns its instances, and each instance must respond to:
#name : identifies the factory by name (default is attr_reader) #klass : returns the associated model class for this factory (default is attr_reader) #create(attrs = {}) : returns a newly created object
Returns the column names for the given ORM model class.
# File lib/pickle/adapter.rb, line 58 def column_names(klass) klass.const_get(:PickleAdapter).column_names(klass) end
# File lib/pickle/adapter.rb, line 74 def create_model(klass, attributes) klass.const_get(:PickleAdapter).create_model(klass, attributes) end
# File lib/pickle/adapter.rb, line 49 def factories raise NotImplementedError, "return an array of factory adapter objects" end
# File lib/pickle/adapter.rb, line 70 def find_all_models(klass, conditions) klass.const_get(:PickleAdapter).find_all_models(klass, conditions) end
# File lib/pickle/adapter.rb, line 66 def find_first_model(klass, conditions) klass.const_get(:PickleAdapter).find_first_model(klass, conditions) end
# File lib/pickle/adapter.rb, line 62 def get_model(klass, id) klass.const_get(:PickleAdapter).get_model(klass, id) end
# File lib/pickle/adapter.rb, line 53 def model_classes @@model_classes ||= self::Base.adapters.map{ |a| a.model_classes }.flatten end
# File lib/pickle/adapter.rb, line 16 def create(attrs = {}) raise NotImplementedError, "create and return an object with the given attributes" end