lib/exegesis.rb in mattly-exegesis-0.2.6 vs lib/exegesis.rb in mattly-exegesis-0.2.8
- old
+ new
@@ -20,14 +20,10 @@
autoload :Design, 'exegesis/design'
autoload :DocumentCollection, 'exegesis/document/collection'
extend self
- def model_classes
- @model_classes ||= {}
- end
-
# extracted from Extlib
#
# Constantize tries to find a declared constant with the name specified
# in the string. It raises a NameError when the name is not in CamelCase
# or is not initialized.
@@ -40,9 +36,14 @@
unless /\A(?:::)?([A-Z]\w*(?:::[A-Z]\w*)*)\z/ =~ camel_cased_word
raise NameError, "#{camel_cased_word.inspect} is not a valid constant name!"
end
Object.module_eval("::#{$1}", __FILE__, __LINE__)
+ end
+
+ # turns class/module names into valid database names
+ def nameify(name)
+ name.gsub(/([a-z])([A-Z])/) { "#{$1}_#{$2.downcase}"}.gsub(/[A-Z]/) {|m| m.downcase }.gsub(/::/,'/')
end
def instantiate(doc, database)
doc = constantize(doc['class']).new(doc)
doc.database = database if doc.respond_to?(:database=)
\ No newline at end of file