ActiveResource::Base#dup should take standard new/create args

dup doesn’t take arguments because in ruby dup doesn’t take arguments. It wouldn’t make sense to break the semantics of ruby just for this, IMO.

Cheers,

-foca

What about initialize_dup?

Not only breaking Ruby semantics, but you can get what you want with this:

some_record.dup.tap do |dup_record|   dup_record.attribute = some_value   self.relationship.dup(reverse_relationship: dup_record) end

What about initialize_dup?

What about it?

-f

I had not considered that. On the other hand:

  • it’s not like dup calls super (which seems wrong to me, now that I think about it)

  • dup with no args would continue to behave exactly the same as it does, now

Kurt

dup doesn't take arguments because in ruby dup doesn't take arguments. It wouldn't make sense to break the semantics of ruby just for this, IMO.

I had not considered that. On the other hand: * it's not like dup calls super (which seems wrong to me, now that I think about it)

Well, the thing is, you are not supposed to redefine #dup, the same way you're not supposed to redefine Class#new and instead use Object#initialize.

With #dup, however, you're supposed to implement #initialize_copy, that takes the object you want to make a shallow copy of.

Cheers, -foca