Class: Pickle::Adapter
- Inherits:
-
Object
- Object
- Pickle::Adapter
- Defined in:
- lib/pickle/adapter.rb
Overview
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
Direct Known Subclasses
Defined Under Namespace
Classes: ActiveRecord, FactoryGirl, Machinist
Instance Attribute Summary collapse
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
12 13 14 |
# File 'lib/pickle/adapter.rb', line 12 def klass @klass end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
12 13 14 |
# File 'lib/pickle/adapter.rb', line 12 def name @name end |
Class Method Details
.factories ⇒ Object
14 15 16 |
# File 'lib/pickle/adapter.rb', line 14 def self.factories raise NotImplementedError, "return an array of factory adapter objects" end |
.model_classes ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/pickle/adapter.rb', line 25 def self.model_classes # remove abstract, framework, and non-table classes @@model_classes ||= ::ActiveRecord::Base.send(:subclasses).reject do |klass| klass.abstract_class? || !klass.table_exists? || (defined?(CGI::Session::ActiveRecordStore::Session) && klass == CGI::Session::ActiveRecordStore::Session) || (defined?(::ActiveRecord::SessionStore::Session) && klass == ::ActiveRecord::SessionStore::Session) end end |
Instance Method Details
#create(attrs = {}) ⇒ Object
18 19 20 |
# File 'lib/pickle/adapter.rb', line 18 def create(attrs = {}) raise NotImplementedError, "create and return an object with the given attributes" end |