Sha256: 6ae687a49ad083069b26eafcf9edf3e381d055adc16265b2e48004f4f463ea82

Contents?: true

Size: 596 Bytes

Versions: 47

Compression:

Stored size: 596 Bytes

Contents

# encoding: utf-8
module Mongoid #:nodoc:
  class Javascript
    # Constant for the file that defines all the js functions.
    FUNCTIONS = File.join(File.dirname(__FILE__), "javascript", "functions.yml")

    # Load the javascript functions and define a class method for each one,
    # that memoizes the value.
    #
    # Example:
    #
    # <tt>Mongoid::Javascript.aggregate</tt>
    YAML.load(File.read(FUNCTIONS)).each_pair do |key, function|
      (class << self; self; end).class_eval <<-EOT
        def #{key}
          @#{key} ||= "#{function}"
        end
      EOT
    end
  end
end

Version data entries

47 entries across 47 versions & 9 rubygems

Version Path
mongoid-braxton-2.0.2 lib/mongoid/javascript.rb
mongoid-2.0.2 lib/mongoid/javascript.rb
mongoid-2.0.1 lib/mongoid/javascript.rb
mongoid-2.0.0 lib/mongoid/javascript.rb
mongoid-2.0.0.rc.8 lib/mongoid/javascript.rb
mongoid-1.9.5 lib/mongoid/javascript.rb
mongoid-2.0.0.rc.7 lib/mongoid/javascript.rb
stonegao-mongoid-2.0.0.rc.6 lib/mongoid/javascript.rb
mongoid-2.0.0.rc.6 lib/mongoid/javascript.rb
mongoid-2.0.0.rc.5 lib/mongoid/javascript.rb
mongoid-2.0.0.rc.4 lib/mongoid/javascript.rb
mongoid-2.0.0.rc.3 lib/mongoid/javascript.rb
mongoid-2.0.0.rc.2 lib/mongoid/javascript.rb
mongoid-2.0.0.rc.1 lib/mongoid/javascript.rb
mongoid-with-auth-1.9.4 lib/mongoid/javascript.rb
mongoid-rails2-1.9.4 lib/mongoid/javascript.rb
mongoid-rails2-1.9.3 lib/mongoid/javascript.rb
mongoid-2.0.0.beta.20 lib/mongoid/javascript.rb
mongoid-2.0.0.beta.19 lib/mongoid/javascript.rb
mongoid-1.9.2 lib/mongoid/javascript.rb