summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2013-03-05 14:51:44 +0100
committerAzul <azul@leap.se>2013-03-06 12:12:48 +0100
commit3caa4dd1bdf2ddc3c32baf4e3add8cd06c37f9f5 (patch)
treeaaa53a1050e945e173c508911131c737acc1b2c1
parenteb6cd0962108412fe92ac8ee2d013d22c0e709d4 (diff)
make sure couchrest actually finds our models in the engines
-rw-r--r--.travis.yml1
-rw-r--r--core/lib/extensions/couchrest.rb52
2 files changed, 39 insertions, 14 deletions
diff --git a/.travis.yml b/.travis.yml
index 44da3cb..1d0939d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,5 +4,6 @@ notifications:
email: false
before_script:
- "bundle exec rake couchrest:migrate_with_proxies"
+ - "bundle exec rake couchrest:migrate_with_proxies" # looks like this needs to run twice
- 'HOST="http://localhost:5984"'
- "curl -X PUT $HOST/_config/admins/anna -d '\"secret\"'"
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