Sha256: c2ce56865d4ba81745bf9672b5f077c70ce76a51ece5ac0177ae1f3b46505c29
Contents?: true
Size: 937 Bytes
Versions: 14
Compression:
Stored size: 937 Bytes
Contents
module BSON # JavaScript code to be evaluated by MongoDB. class Code # Hash mapping identifiers to their values attr_accessor :scope, :code # 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. 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 def length @code.length end def ==(other) self.class == other.class && @code == other.code && @scope == other.scope end def inspect "<BSON::Code:#{object_id} @data=\"#{@code}\" @scope=\"#{@scope.inspect}\">" end def to_bson_code self end end end
Version data entries
14 entries across 14 versions & 1 rubygems