So allows say I've got a class like below

class List
  include DataMapper::Resource
  property :id, Serial  
  property :username, String

  def self.my_username
    return self[:username]
  end
end

list=List.create(:username=>,'jim')
list.my_username

After I run this it informs me the method can't be found, as well as on more analysis that you could only define class techniques(not object techniques) which class techniques don't get access to objects data.

Can there be in whatever way to possess these techniques incorporated as object techniques and obtain access to object data? I am using Ruby 1.8.6 and also the latest version of datamapper.

Avoid all self also it become InstanceMethod :

class List
  include DataMapper::Resource
  property :id, Serial  
  property :username, String

  def my_username
    return self[:username]
  end
end

list=List.create(:username=>'jim')
list.my_username

You are able to think about the course scope because the Model (a table within an RDBMS) as well as the instance scope because the Resource (a row within an RDBMS). If you define class techniques (as if you did with self.my_username) you're operating around the Model (also known as the table, also known as all rows). Should you define instance techniques, these is going to be open to a Resource(also known as one row).

Typical usecases for class techniques are to develop (chains of) query/ies. These will essentially try to exactly the same effect as Active Record's 2.x named_scope. You are able to call a series of sophistication techniques and also have it not perform single query, as lengthy while you don't clearly access the information the query should really provide. DataMapper could keep on creating and modifying query objects up until the moment you really have to access the information. This only works if every class method within the chain returns a clear case of DataMapper::Collection that is typically accomplished by coming back caused by calls to all (or mixing these with set operators like +, -, & and |.