Sha256: 69fabd67b33609d5d2695ded06655129672a97422f6aa692825c53c09b6df6ac

Contents?: true

Size: 601 Bytes

Versions: 188

Compression:

Stored size: 601 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 Get the function.
    #   Mongoid::Javascript.aggregate
    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

188 entries across 96 versions & 4 rubygems

Version Path
classiccms-0.3.7 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/javascript.rb
classiccms-0.3.7 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/javascript.rb
classiccms-0.3.7 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/javascript.rb
classiccms-0.3.6 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/javascript.rb
classiccms-0.3.6 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/javascript.rb
classiccms-0.3.6 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/javascript.rb
classiccms-0.3.5 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/javascript.rb
classiccms-0.3.5 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/javascript.rb
classiccms-0.3.5 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/javascript.rb
mongoid-2.4.11 lib/mongoid/javascript.rb
classiccms-0.3.4 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/javascript.rb
classiccms-0.3.4 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/javascript.rb
classiccms-0.3.4 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/javascript.rb
classiccms-0.3.3 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/javascript.rb
classiccms-0.3.3 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/javascript.rb
classiccms-0.3.3 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/javascript.rb
classiccms-0.3.2 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/javascript.rb
classiccms-0.3.2 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/javascript.rb
classiccms-0.3.2 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/javascript.rb
classiccms-0.3.1 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/javascript.rb