class Rails::Generators::ActiveModel


instead of self.new.
The only exception in ActiveModel for ActiveRecord is the use of self.build
builder.save # => “@foo.save”
builder = ActiveRecord::Generators::ActiveModel.new “@foo”
receive the calls:
On initialization, the ActiveModel accepts the instance name that will
# => “Foo.get(params)”
Datamapper::Generators::ActiveModel.find(Foo, “params”)
# => “Foo.find(params)”
ActiveRecord::Generators::ActiveModel.find(Foo, “params”)
For example:
string that matches the ORM API.
The API has the same methods as ActiveRecord, but each method returns a
generate customized controller code.
ActiveModel is a class to be implemented by each ORM to allow Rails to

def self.all(klass)

GET index
def self.all(klass)
  "#{klass}.all"
end

def self.build(klass, params=nil)

POST create
GET new
def self.build(klass, params=nil)
  if params
    "#{klass}.new(#{params})"
  else
    "#{klass}.new"
  end
end

def self.find(klass, params=nil)

DELETE destroy
PUT update
GET edit
GET show
def self.find(klass, params=nil)
  "#{klass}.find(#{params})"
end

def destroy

DELETE destroy
def destroy
  "#{name}.destroy"
end

def errors

PUT update
POST create
def errors
  "#{name}.errors"
end

def initialize(name)

def initialize(name)
  @name = name
end

def save

POST create
def save
  "#{name}.save"
end

def update_attributes(params=nil)

PUT update
def update_attributes(params=nil)
  "#{name}.update_attributes(#{params})"
end