Class: Pickle::Adapter::Fabrication

Inherits:
Pickle::Adapter show all
Defined in:
lib/pickle/adapter.rb

Overview

fabrication adapter

Instance Attribute Summary

Attributes inherited from Pickle::Adapter

#klass, #name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Pickle::Adapter

column_names, create_model, find_all_models, find_first_model, get_model, model_classes

Constructor Details

#initialize(factory) ⇒ Fabrication



146
147
148
149
150
# File 'lib/pickle/adapter.rb', line 146

def initialize(factory)
  if defined? ::Fabrication
    @klass, @name = factory[1].klass, factory[0].to_s
  end
end

Class Method Details

.factoriesObject



137
138
139
140
141
142
143
144
# File 'lib/pickle/adapter.rb', line 137

def self.factories
  if defined? ::Fabrication
    ::Fabrication::Support.find_definitions if ::Fabrication::Fabricator.schematics.empty?
    ::Fabrication::Fabricator.schematics.collect{|v| new(v)}
  else
    []
  end
end

Instance Method Details

#create(attrs = {}) ⇒ Object



152
153
154
155
156
157
158
# File 'lib/pickle/adapter.rb', line 152

def create(attrs = {})
  if defined? ::Fabrication
    ::Fabrication::Fabricator.generate(@name.to_sym, {
        :save => true
        }, attrs)
  end
end