From 04376c286daee0165f6544ecdafaa645aa7695c0 Mon Sep 17 00:00:00 2001 From: Azul Date: Sat, 22 Dec 2012 15:51:24 +0100 Subject: moving the js for view definitions into separate files This way we get syntax highlighting and so on. --- core/lib/extensions/couchrest.rb | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'core') diff --git a/core/lib/extensions/couchrest.rb b/core/lib/extensions/couchrest.rb index a8da23b..0dca632 100644 --- a/core/lib/extensions/couchrest.rb +++ b/core/lib/extensions/couchrest.rb @@ -1,8 +1,21 @@ -class CouchRest::Model::Designs::View - - # so we can called Ticket.method.descending or Ticket.method.ascending - def ascending - self - end +module CouchRest::Model::Designs + + class View + + # so we can called Ticket.method.descending or Ticket.method.ascending + def ascending + self + end + end + + class DesignMapper + def load_views(dir) + Dir.glob("#{dir}/*.js") do |js| + name = File.basename(js, '.js') + file = File.open(js, 'r') + view name.to_sym, :map => file.read + end + end + end end -- cgit v1.2.3