Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Item
- include DataMapper::Resource
- property :name, String, :key => true
- has n, :dosages
- has n, :producing_recipes, :class_name => 'Recipe',
- :child_key => [:product_name]
- has n, :consuming_recipes, :class_name => 'Recipe',
- :through => :dosages,
- :remote_relationship_name => :recipe
- # Only this one is not working
- has n, :derivatives, :class_name => 'Item',
- :through => :consuming_recipes,
- :near_relationship_name => :product
- has n, :materials, :class_name => 'Item',
- :through => :producing_recipes,
- :remote_relationship_name =>
- :ingredients,
- :child_key => [:product_name]
- end
- class Recipe
- include DataMapper::Resource
- property :id, Serial
- belongs_to :product, :class_name => 'Item',
- :child_key => [:product_name]
- has n, :dosages
- has n, :ingredients, :class_name => 'Item',
- :through => :dosages,
- :remote_relationship_name => :item
- end
- class Stack
- include DataMapper::Resource
- property :id, Serial
- property :type, Discriminator
- property :quantity, Integer
- property :item_name, String
- belongs_to :item
- end
- class Dosage < Stack
- property :recipe_id, Integer
- belongs_to :recipe
- end
Add Comment
Please, Sign In to add comment