Sha256: 37ee255175e4ba7b2f071097b3a8adaf33f1e5da85f8935a3b7cda96a21d8f22

Contents?: true

Size: 661 Bytes

Versions: 19

Compression:

Stored size: 661 Bytes

Contents

# encoding: utf-8
module Mongoid #:nodoc:
  module Gator
    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
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
gatoroid-0.2.17 lib/gator/javascript.rb
gatoroid-0.2.16 lib/gator/javascript.rb
gatoroid-0.2.15 lib/gator/javascript.rb
gatoroid-0.2.14 lib/gator/javascript.rb
gatoroid-0.2.13 lib/gator/javascript.rb
gatoroid-0.2.12 lib/gator/javascript.rb
gatoroid-0.2.11 lib/gator/javascript.rb
gatoroid-0.2.10 lib/gator/javascript.rb
gatoroid-0.2.9 lib/gator/javascript.rb
gatoroid-0.2.8 lib/gator/javascript.rb
gatoroid-0.2.7 lib/gator/javascript.rb
gatoroid-0.2.6 lib/gator/javascript.rb
gatoroid-0.2.5 lib/gator/javascript.rb
gatoroid-0.2.4 lib/gator/javascript.rb
gatoroid-0.2.3 lib/gator/javascript.rb
gatoroid-0.2.2 lib/gator/javascript.rb
gatoroid-0.2.1 lib/gator/javascript.rb
gatoroid-0.2.0 lib/gator/javascript.rb
gatoroid-0.1.0 lib/gator/javascript.rb