Class: Pickle::Adapter::Orm

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

Overview

ORM adapter. If you have no factory adapter, you can use this adapter to use your orm as ‘factory’ - ie create objects

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(klass) ⇒ Orm

Returns a new instance of Orm.



128
129
130
# File 'lib/pickle/adapter.rb', line 128

def initialize(klass)
  @klass, @name = klass, klass.name.underscore.gsub('/','_')
end

Class Method Details

.factoriesObject



124
125
126
# File 'lib/pickle/adapter.rb', line 124

def self.factories
  model_classes.map{|k| new(k)}
end

Instance Method Details

#create(attrs = {}) ⇒ Object



132
133
134
# File 'lib/pickle/adapter.rb', line 132

def create(attrs = {})
  Pickle::Adapter.create_model(@klass, attrs)
end