Class: Vines::Services::CouchModels::Upload
- Inherits:
-
CouchRest::Model::Base
- Object
- CouchRest::Model::Base
- Vines::Services::CouchModels::Upload
show all
- Extended by:
- Storage::CouchDB::ClassMethods
- Defined in:
- lib/vines/services/storage/couchdb/upload.rb
Constant Summary
collapse
- KEYS =
%w[_id name size labels created_at updated_at].freeze
Class Method Summary
collapse
Instance Method Summary
collapse
build_from_database, to_s
Class Method Details
.find_all ⇒ Object
60
61
62
|
# File 'lib/vines/services/storage/couchdb/upload.rb', line 60
def self.find_all
by_name.map {|doc| doc.to_result }
end
|
.find_by_label(label) ⇒ Object
52
53
54
|
# File 'lib/vines/services/storage/couchdb/upload.rb', line 52
def self.find_by_label(label)
by_label.key(label).map {|doc| doc.to_result }
end
|
.find_by_name(name) ⇒ Object
56
57
58
|
# File 'lib/vines/services/storage/couchdb/upload.rb', line 56
def self.find_by_name(name)
first_from_view('by_name', name)
end
|
.find_labels ⇒ Object
47
48
49
50
|
# File 'lib/vines/services/storage/couchdb/upload.rb', line 47
def self.find_labels
view = by_label.reduce.group
view.rows.map {|row| {name: row['key'], size: row['value']} }
end
|
Instance Method Details
#to_result ⇒ Object
42
43
44
45
|
# File 'lib/vines/services/storage/couchdb/upload.rb', line 42
def to_result
to_hash.clone.keep_if {|k, v| KEYS.include?(k) }
.tap {|h| h['id'] = h.delete('_id') }
end
|