summaryrefslogtreecommitdiff
path: root/core/lib/extensions
diff options
context:
space:
mode:
authorjessib <jessib@riseup.net>2013-12-02 11:56:04 -0800
committerjessib <jessib@riseup.net>2013-12-02 11:56:04 -0800
commit2a2ffd46bf4e6009f2957fb4e4abdedbfa7e3245 (patch)
tree41dd790266aaa951dfa35889527f78015f8c4451 /core/lib/extensions
parent8e9b65b01bbd9d44d4077d94f2dc4ac375cf8e85 (diff)
parent8de6f143e53af5287b41913dcf3c7969f452fbc9 (diff)
Merge branch 'develop' into feature/service_level
Diffstat (limited to 'core/lib/extensions')
-rw-r--r--core/lib/extensions/couchrest.rb35
1 files changed, 26 insertions, 9 deletions
diff --git a/core/lib/extensions/couchrest.rb b/core/lib/extensions/couchrest.rb
index 91dfc1c..84cfbb3 100644
--- a/core/lib/extensions/couchrest.rb
+++ b/core/lib/extensions/couchrest.rb
@@ -47,28 +47,45 @@ module CouchRest
def self.load_all_models_with_engines
self.load_all_models_without_engines
return unless defined?(Rails)
- Dir[Rails.root + 'app/models/**/*.rb'].each do |path|
- require path
- end
Dir[Rails.root + '*/app/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)
+ class << self
+ alias_method_chain :load_all_models, :engines
+ end
+
+ def dump_all_models
+ prepare_directory
+ find_models.each do |model|
+ model.design_docs.each do |design|
+ dump_design(model, design)
+ end
+ end
end
+ protected
+ def dump_design(model, design)
+ dir = prepare_directory model.name.tableize
+ filename = design.id.sub('_design/','') + '.json'
+ puts dir + filename
+ design.checksum
+ File.open(dir + filename, "w") do |file|
+ file.write(JSON.pretty_generate(design.to_hash))
+ end
+ end
- class << self
- alias_method_chain :load_all_models, :engines
+ def prepare_directory(dir = '')
+ dir = Rails.root + 'tmp' + 'designs' + dir
+ Dir.mkdir(dir) unless Dir.exists?(dir)
+ return dir
end
end
end
+
end
class ModelRailtie