Class: SimplyStored::Couch::Views::DeletedModelViewSpec
- Inherits:
-
CouchPotato::View::CustomViewSpec
- Object
- CouchPotato::View::CustomViewSpec
- SimplyStored::Couch::Views::DeletedModelViewSpec
- Defined in:
- lib/simply_stored/couch/views/deleted_model_view_spec.rb
Instance Method Summary collapse
- #map_function ⇒ Object
- #process_results(results) ⇒ Object
- #reduce_function ⇒ Object
- #view_parameters ⇒ Object
Instance Method Details
#map_function ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/simply_stored/couch/views/deleted_model_view_spec.rb', line 5 def map_function <<-eos function(doc) { if (doc.ruby_class && doc.ruby_class == '#{@klass.name}') { if (doc['#{@klass.soft_delete_attribute}'] && doc['#{@klass.soft_delete_attribute}'] != null){ // "soft" deleted }else{ emit(doc.created_at, 1); } } } eos end |
#process_results(results) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/simply_stored/couch/views/deleted_model_view_spec.rb', line 32 def process_results(results) if count? results['rows'].first.try(:[], 'value') || 0 else results['rows'].map { |row| row['doc'] || row['id'] } end end |
#reduce_function ⇒ Object
19 20 21 |
# File 'lib/simply_stored/couch/views/deleted_model_view_spec.rb', line 19 def reduce_function '_sum' end |
#view_parameters ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/simply_stored/couch/views/deleted_model_view_spec.rb', line 23 def view_parameters _super = super if _super[:reduce] _super else {:include_docs => true, :reduce => false}.merge(_super) end end |