Class: BSON::Code
Overview
JavaScript code to be evaluated by MongoDB.
Instance Attribute Summary (collapse)
-
- (Object) code
Hash mapping identifiers to their values.
-
- (Object) scope
Hash mapping identifiers to their values.
Instance Method Summary (collapse)
- - (Object) ==(other)
-
- (Code) initialize(code, scope = {})
constructor
Wrap code to be evaluated by MongoDB.
- - (Object) inspect
- - (Object) length
- - (Object) to_bson_code
Constructor Details
- (Code) initialize(code, scope = {})
Wrap code to be evaluated by MongoDB.
32 33 34 35 36 37 38 39 |
# File 'lib/bson/types/code.rb', line 32 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 |
Instance Attribute Details
- (Object) code
Hash mapping identifiers to their values
25 26 27 |
# File 'lib/bson/types/code.rb', line 25 def code @code end |
- (Object) scope
Hash mapping identifiers to their values
25 26 27 |
# File 'lib/bson/types/code.rb', line 25 def scope @scope end |
Instance Method Details
- (Object) ==(other)
45 46 47 48 |
# File 'lib/bson/types/code.rb', line 45 def ==(other) self.class == other.class && @code == other.code && @scope == other.scope end |
- (Object) inspect
50 51 52 |
# File 'lib/bson/types/code.rb', line 50 def inspect "<BSON::Code:#{object_id} @data=\"#{@code}\" @scope=\"#{@scope.inspect}\">" end |
- (Object) length
41 42 43 |
# File 'lib/bson/types/code.rb', line 41 def length @code.length end |
- (Object) to_bson_code
54 55 56 |
# File 'lib/bson/types/code.rb', line 54 def to_bson_code self end |