lib/cistern/service.rb in cistern-0.5.4 vs lib/cistern/service.rb in cistern-0.5.6

- old
+ new

@@ -35,10 +35,14 @@ EOS klass.send(:const_set, :Timeout, Class.new(Cistern::Error)) end + def collection_path(collection_path) + @collection_path = collection_path + end + def model_path(model_path) @model_path = model_path end def request_path(request_path) @@ -125,10 +129,17 @@ end EOS end end collections.each do |collection, options| - require File.join(@model_path, collection.to_s) unless options[:require] == false + unless options[:require] == false + if @collection_path + require File.join(@collection_path, collection.to_s) + else + require File.join(@model_path, collection.to_s) + end + end + class_name = collection.to_s.split("_").map(&:capitalize).join self.const_get(:Collections).module_eval <<-EOS, __FILE__, __LINE__ def #{collection}(attributes={}) #{service}::#{class_name}.new({connection: self}.merge(attributes)) end