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, method) ⇒ Machinist
constructor
A new instance of Machinist.
Methods inherited from Pickle::Adapter
Constructor Details
#initialize(klass, method) ⇒ Machinist
45 46 47 48 |
# File 'lib/pickle/adapter.rb', line 45 def initialize(klass, method) @klass, @method = klass, method @name = (@method =~ /make_/ ? "#{@method.sub('make_','')}_" : "") + @klass.name.underscore.gsub('/','_') end |
Class Method Details
.factories ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/pickle/adapter.rb', line 33 def self.factories factories = [] model_classes.each do |klass| factories << new(klass, "make") if klass.instance_variable_get('@blueprint') # if there are make_<special> methods, add blueprints for them klass.methods.select{|m| m =~ /^make_/ && m !~ /_unsaved$/}.each do |method| factories << new(klass, method) end end factories end |
Instance Method Details
#create(attrs = {}) ⇒ Object
50 51 52 |
# File 'lib/pickle/adapter.rb', line 50 def create(attrs = {}) @klass.send(@method, attrs) end |