Skip to content

Instantly share code, notes, and snippets.

@lifo
Created January 15, 2009 17:33
Show Gist options
  • Save lifo/47499 to your computer and use it in GitHub Desktop.
Save lifo/47499 to your computer and use it in GitHub Desktop.
class RailsHelpers
def form_for(object)
is_record_new = api_hook_record_new(object)
end
private
def api_hook_record_new(object)
# option 1 : raise "Should be overridden by ORM"
# option 2 : object.new_record?
end
end
module RailsDataMapper
def api_hook_record_new(object)
if object.is_a?(DataMapper)
object.do_dm_stuff
else
super
end
end
end
class RailsHelpers
def form_for(object)
is_record_new = ActiveORM::Base.determine_orm_and_initialize(object).new_record?
end
end
class RailsDataMapper < ActiveORM::Base
def initialize(object)
@object = object
end
def new_record?
@object.new?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment