JavaScript code to be evaluated by MongoDB.
Hash mapping identifiers to their values
Hash mapping identifiers to their values
Wrap code to be evaluated by MongoDB.
@param [String] code the JavaScript code. @param [Hash] a document mapping identifiers to values, which
represent the scope in which the code is to be executed.
# File lib/bson/types/code.rb, line 28 def initialize(code, scope={}) @code = code @scope = scope unless @code.is_a?(String) raise ArgumentError, "BSON::Code must be in the form of a String; #{@code.class} is not allowed." end end
# File lib/bson/types/code.rb, line 41 def ==(other) self.class == other.class && @code == other.code && @scope == other.scope end
# File lib/bson/types/code.rb, line 46 def inspect "<BSON::Code:#{object_id} @data=\"#{@code}\" @scope=\"#{@scope.inspect}\">" end
# File lib/bson/types/code.rb, line 37 def length @code.length end
# File lib/bson/types/code.rb, line 50 def to_bson_code self end