Take the 2-minute tour ×

Is it possible to set up something you could call a "fake property" in a DataMapper model? What I mean is, a property that isn't persisted, but that is still modifiable using create() or update(). Instead of persisting the data in the data store, a function would be called instead with the value.

share|improve this question
add comment

2 Answers

Turns out that create() and update() do nothing more than self.property = value.

share|improve this answer
add comment

Use attr_accessor in your model like this:

class Account
  include DataMapper::Resource
  attr_accessor :password

The method is explained here what is attr_accessor in datamapper - ruby

share|improve this answer
add comment

Your Answer


