lib/mongoscript/multiquery.rb in mongoscript-0.0.8 vs lib/mongoscript/multiquery.rb in mongoscript-0.0.9
- old
+ new
@@ -1,34 +1,30 @@
module MongoScript
module Multiquery
+ extend ActiveSupport::Concern
+ # An error class representing Mongo queries that for some reason failed in the Javascript.
+ # This error will never be raised; instead it will be returned as an object in the results array.
class QueryFailedError < RuntimeError
# The original query whose execution failed.
attr_accessor :query_parameters
# The name of the original query
attr_accessor :query_name
# The response from the multiquery Javascript.
attr_accessor :db_response
+ # Initialize the error, and set its backtrace.
def initialize(name, query, response)
@query_name = name
@query_parameters = query
@db_response = response
super("Query #{@query_name} failed with the following response: #{response.inspect}")
# set the backtrace to everything that's going on except this initialize method
set_backtrace(caller[1...caller.length])
end
end
- # @private
- def self.included(base)
- base.class_eval do
- extend MongoScript::Multiquery::ClassMethods
- end
- end
-
module ClassMethods
-
# Runs multiple find queries at once,
# returning the results keyed to the original query names.
# If a query produces an error, its result will be a QueryFailedError object
# with the appropriate details; other queries will be unaffected.
#
\ No newline at end of file