class Package
include DataMapper::Resource
property :id, Serial
property :product, String, :required => true
def self.create(attributes = {})
puts 'I am in the Object method'
#do something here with value of product before creating a new row
create(attributes)
end
end
p = Package.new
p.create :product=>'myprod'
I actually want a wrapper around "create" method provided by Datamapper. So that before creating a row in Package table, I can do something with the value of "product". But above implementation is wrong and it seems it gets lost in circular calls. I get
.......
.......
I am in the Object method
I am in the Object method
I am in the Object method
I am in the Object method
I am in the Object method
I am in the Object method
I am in the Object method
I am in the Object method
I am in the Object method
SystemStackError - stack level too deep:
What am I doing wrong? and how can I achieve my goal