initial commit

This commit is contained in:
2012-08-22 18:15:37 +02:00
commit 0856528f5e
120 changed files with 3048 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
class Table
include SimplyStored::Couch
property :number, type: Fixnum, default: 1
belongs_to :supplier
has_many :lists
validates :supplier_id, presence: true
#validates :list_id, presence: true
validates :number, numericality: {greater_than: 0}
view :active_lists, type: :custom, map_function: %|function(doc){
if(doc.ruby_class == 'List' && doc.state == 'active'){
emit(doc._id, 1);
}
}|, reduce_function: '_sum'
def occupied?
not self.class.database.view(self.class.active_lists(key: list_id, reduce: true)).zero?
end
end