From afd4beb6af150508cd9f6cd7874a86160fc0d660 Mon Sep 17 00:00:00 2001 From: priit.mx.ee Date: Tue, 18 Nov 2008 20:02:48 +0200 Subject: [PATCH] couchrest-type change to couchrest_type --- lib/couchrest/core/model.rb | 16 ++++++++-------- spec/couchrest/core/model_spec.rb | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/couchrest/core/model.rb b/lib/couchrest/core/model.rb index 3d79d2c..1ef3804 100644 --- a/lib/couchrest/core/model.rb +++ b/lib/couchrest/core/model.rb @@ -27,7 +27,7 @@ module CouchRest # view_by :tags, # :map => # "function(doc) { - # if (doc['couchrest-type'] == 'Article' && doc.tags) { + # if (doc['couchrest_type'] == 'Article' && doc.tags) { # doc.tags.forEach(function(tag){ # emit(tag, 1); # }); @@ -76,7 +76,7 @@ module CouchRest apply_defaults cast_keys unless self['_id'] && self['_rev'] - self['couchrest-type'] = self.class.to_s + self['couchrest_type'] = self.class.to_s end end @@ -108,7 +108,7 @@ module CouchRest new(doc) end - # Load all documents that have the "couchrest-type" field equal to the + # Load all documents that have the "couchrest_type" field equal to the # name of the current class. Take thes the standard set of # CouchRest::Database#view options. # def all opts = {} @@ -220,7 +220,7 @@ module CouchRest # view_by :tags, # :map => # "function(doc) { - # if (doc['couchrest-type'] == 'Post' && doc.tags) { + # if (doc['couchrest_type'] == 'Post' && doc.tags) { # doc.tags.forEach(function(tag){ # emit(doc.tag, 1); # }); @@ -236,7 +236,7 @@ module CouchRest # function: # # function(doc) { - # if (doc['couchrest-type'] == 'Post' && doc.date) { + # if (doc['couchrest_type'] == 'Post' && doc.date) { # emit(doc.date, null); # } # } @@ -293,7 +293,7 @@ module CouchRest # key_emit = doc_keys.length == 1 ? "#{doc_keys.first}" : "[#{doc_keys.join(', ')}]" # map_function = <<-JAVASCRIPT # function(doc) { - # if (#{!ducktype ? "doc['couchrest-type'] == '#{type}' && " : ""}#{key_protection}) { + # if (#{!ducktype ? "doc['couchrest_type'] == '#{type}' && " : ""}#{key_protection}) { # emit(#{key_emit}, null); # } # } @@ -388,7 +388,7 @@ module CouchRest "views" => { 'all' => { 'map' => "function(doc) { - if (doc['couchrest-type'] == '#{self.to_s}') { + if (doc['couchrest_type'] == '#{self.to_s}') { emit(null,null); } }" @@ -464,4 +464,4 @@ module CouchRest register_instance_hooks :save, :create, :update, :destroy end # class Model -end # module CouchRest \ No newline at end of file +end # module CouchRest diff --git a/spec/couchrest/core/model_spec.rb b/spec/couchrest/core/model_spec.rb index de67099..23c0a7d 100644 --- a/spec/couchrest/core/model_spec.rb +++ b/spec/couchrest/core/model_spec.rb @@ -45,7 +45,7 @@ class Article < CouchRest::Model view_by :tags, :map => "function(doc) { - if (doc['couchrest-type'] == 'Article' && doc.tags) { + if (doc['couchrest_type'] == 'Article' && doc.tags) { doc.tags.forEach(function(tag){ emit(tag, 1); }); @@ -276,7 +276,7 @@ describe CouchRest::Model do end it "should set the type" do - @obj['couchrest-type'].should == 'Basic' + @obj['couchrest_type'].should == 'Basic' end end @@ -576,4 +576,4 @@ __END__ lambda{Basic.get(@obj.id)}.should raise_error end end -end \ No newline at end of file +end -- 1.5.6.3