#1141 ✓resolved
Anna Gabutero

Can't override attribute setters with module methods in DataMapper 0.10

Reported by Anna Gabutero | December 2nd, 2009 @ 09:29 AM

Consider the following code:

require 'dm-core'

module MyModule
  def name=(n)
    attribute_set(:name, n.downcase)
  end
end

class A
  include DataMapper::Resource

  property :id, Serial
  property :name, String

  def name=(n)
    attribute_set(:name, n.downcase)
  end
end

class B
  include DataMapper::Resource
  include MyModule

  property :id, Serial
  property :name, String
end

I expect that using name= in an instance of A or B will set the name attribute to the lowercase version of whatever I passed it.

This worked as expected in DataMapper 0.9.11. However only instances of class A behave as expected in DataMapper 0.10.1.

Comments and changes to this ticket

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 »

Tags

Pages