summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorazul <azul@riseup.net>2013-03-14 07:36:54 -0700
committerazul <azul@riseup.net>2013-03-14 07:36:54 -0700
commit869ba2f363a48d0f76321efc08a228f54aeb6758 (patch)
tree00944b79cd5abb5058ac2ea432c32ea433b1aebd /core
parent886585a0f673e0ea70abb99504ff9c70180361d5 (diff)
parent1f874dc62e0d0add285f6ab5ff1b6d8fccaa1912 (diff)
Merge pull request #37 from azul/feature/migration-flow
Migration flow for couch db
Diffstat (limited to 'core')
-rw-r--r--core/lib/extensions/couchrest.rb52
1 files changed, 38 insertions, 14 deletions
diff --git a/core/lib/extensions/couchrest.rb b/core/lib/extensions/couchrest.rb
index ca4b608..57bb837 100644
--- a/core/lib/extensions/couchrest.rb
+++ b/core/lib/extensions/couchrest.rb
@@ -1,26 +1,50 @@
module CouchRest
- module Model::Designs
+ module Model
+ module Designs
- class View
+ class View
- # so we can called Ticket.method.descending or Ticket.method.ascending
- def ascending
- self
+ # so we can called Ticket.method.descending or Ticket.method.ascending
+ def ascending
+ self
+ end
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,
- :reduce => "function(key, values, rereduce) { return sum(values); }"
+ 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,
+ :reduce => "function(key, values, rereduce) { return sum(values); }"
+ end
end
end
end
+ class Migrate
+ def self.load_all_models_with_engines
+ self.load_all_models_without_engines
+ return unless defined?(Rails)
+ Dir[Rails.root + '**/models/**/*.rb'].each do |path|
+ require path
+ end
+ end
+
+ def self.all_models_and_proxies
+ callbacks = migrate_each_model(find_models)
+ callbacks += migrate_each_proxying_model(find_proxying_models)
+ cleanup(callbacks)
+ end
+
+
+
+ class << self
+ alias_method_chain :load_all_models, :engines
+ end
+
+ end
end
class ModelRailtie