-
Notifications
You must be signed in to change notification settings - Fork 1
Entities
aaronbee edited this page Sep 14, 2010
·
8 revisions
The basics are the following:
Suppose we have a User entity with a field name.
u = User.new creates a new user.
u.name gets the name attribute.
u.put("name", "Alice") sets the name attribute to “Alice”.
u.name = "Alice" does the same as above as long as you have the following line in your User model:
include PIQLEntity
Right now it is required that there is a file in the models directory for each entity, lowercased.
Anytime you read or write from the database you need to pass in $piql_env as the last argument.
u.save($piql_env) saves the user to the database.
- The models directory of your Rails app should have files that are the lowercased name of each Entity.
- This file should include a class definition with a name matching the Entity. The class should not inherit from anything.
- The class should mix-in (ie.
include)PIQLEntity
For example, the Entity user would have a file app/models/user.rb that looks like the following: