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

- (Orm) initialize(klass)

Returns a new instance of Orm



168
169
170
# File 'lib/pickle/adapter.rb', line 168

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

Class Method Details

+ (Object) factories



164
165
166
# File 'lib/pickle/adapter.rb', line 164

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

Instance Method Details

- (Object) create(attrs = {})



172
173
174
# File 'lib/pickle/adapter.rb', line 172

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