Class: Pickle::Adapter::Machinist
- Inherits:
-
Pickle::Adapter
- Object
- Pickle::Adapter
- Pickle::Adapter::Machinist
- Defined in:
- lib/pickle/adapter.rb
Overview
machinist adapter
Instance Attribute Summary
Attributes inherited from Pickle::Adapter
Class Method Summary collapse
Instance Method Summary collapse
- #create(attrs = {}) ⇒ Object
-
#initialize(klass, blueprint) ⇒ Machinist
constructor
A new instance of Machinist.
Methods inherited from Pickle::Adapter
column_names, create_model, find_all_models, find_first_model, get_model, model_classes
Constructor Details
#initialize(klass, blueprint) ⇒ Machinist
Returns a new instance of Machinist.
91 92 93 94 95 |
# File 'lib/pickle/adapter.rb', line 91 def initialize(klass, blueprint) @klass, @blueprint = klass, blueprint @name = @klass.name.underscore.gsub('/','_') @name = "#{@blueprint}_#{@name}" unless @blueprint == :master end |
Class Method Details
.factories ⇒ Object
81 82 83 84 85 86 87 88 89 |
# File 'lib/pickle/adapter.rb', line 81 def self.factories factories = [] model_classes.each do |klass| if blueprints = klass.instance_variable_get('@blueprints') blueprints.keys.each {|blueprint| factories << new(klass, blueprint)} end end factories end |
Instance Method Details
#create(attrs = {}) ⇒ Object
97 98 99 100 101 102 103 |
# File 'lib/pickle/adapter.rb', line 97 def create(attrs = {}) if @klass.respond_to?('make!') @klass.send(:make!, @blueprint, attrs) else @klass.send(:make, @blueprint, attrs) end end |