#755 ✓resolved
dan (at angryamoeba)

DataMapper renders stdlib's URI class inaccessible

Reported by dan (at angryamoeba) | January 8th, 2009 @ 06:28 AM

DataMapper provides URI as a metatype for properties, which is great, but immediately sets up a constant conflict with the ruby standard library. In our application where model changes trigger callbacks to external services, this becomes an issue:

class URIHack; def self.parse(arg); URI.parse(arg); end; end;

class MyModel
include DataMapper::Resource

def parse_uri(arg)

Comments and changes to this ticket

  • Lin Jen-Shin

    Lin Jen-Shin January 8th, 2009 @ 10:53 AM

    Perhaps you could use ::URI to indicate top level URI came from stdlib in parse_uri.

  • dan (at angryamoeba)

    dan (at angryamoeba) January 8th, 2009 @ 11:02 AM

    Yes, my example is deliberately awful. But I don't think DM should be conflicting with the stdlib in any way - just my opinion.

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) January 8th, 2009 @ 02:00 PM

    • State changed from “unconfirmed” to “resolved”
    • Assigned user set to “Dan Kubb (dkubb)”

    This won't be an issue in dkubb/dm-core.

    In sam/dm-core we included the DataMapper::Types namespace into the models, which includes DM::Types::URI. This conflicted with the built-in URI, as mentioned.

    In dkubb/dm-core we don't include the DataMapper::Types namespace into the models at all. Instead we let you use the stdlib URI constant, and inside Model#property, we see if there is a similarly named DM::Types class, and remap it to use that.

    It seems to work out really well, and eliminates this problem altogether.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »