Created
January 15, 2009 17:33
-
-
Save lifo/47499 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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