Module: MongoScript::Execution

Included in:
MongoScript
Defined in:
lib/mongoscript/execution.rb

Overview

Execute raw code on the Mongo server code_for can longer term, we could store functions on the server and have deploy tasks that delete all and reinstall stored method on deploys see neovintage.blogspot.com/2010/07/mongodb-stored-javascript-functions.html 10gen recommends not using stored functions, but that’s mainly b/c they should be stored and versioned with other code but a cool 6W gem for automatically clearing and installing such code would meet that objection see www.mongodb.org/display/DOCS/Server-side+Code+Execution#Server-sideCodeExecution-Storingfunctionsserverside

Defined Under Namespace

Modules: ClassMethods Classes: ExecutionFailure, NoScriptDirectory, ScriptNotFound

Constant Summary collapse

LOADED_SCRIPTS =
{}

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/mongoscript/execution.rb', line 22

def self.included(base)
  base.class_eval do
    class << self
      attr_accessor :script_dirs
    end

    def self.gem_path
      mongoscript = Bundler.load.specs.find {|s| s.name == "mongoscript"}
      File.join(mongoscript.full_gem_path, "lib", "mongoscript", "javascripts")
    end

    # start out with the scripts provided by the gem
    @script_dirs = [gem_path]

    extend MongoScript::Execution::ClassMethods
  end
end