Sha256: c3fd3afe31427452b98dc29d44fb20cd7116cf8b379654853664695881e3188b

Contents?: true

Size: 663 Bytes

Versions: 3

Compression:

Stored size: 663 Bytes

Contents

class Chillfile::Model::SyncFile < Chillfile::Model::Base
  timestamps!
  property :checksum, String
  property :paths, [String]
  
  # alternative to paths.empty?
  property :deleted, TrueClass, :default => false
  
  validates_uniqueness_of :checksum
  
  view_by :checksum
  
  view_by :filesystem, :map => "
    function(doc) {
      if (doc['type'] == 'Chillfile::Model::SyncFile') {
        for (var i = 0; i < doc['paths'].length; i++) {
          emit(null, [doc['checksum'], doc['paths'][i]]);
        }
      }
    }
  "
  
  def self.by_filesystem_raw
    self.by_filesystem(:include_docs => false)["rows"].map do |f|
      f["value"]
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
chillfile-0.0.3 lib/chillfile/model/sync_file.rb
chillfile-0.0.2 lib/chillfile/model/sync_file.rb
chillfile-0.0.1 lib/chillfile/model/sync_file.rb