Class: BSON::Code
- Inherits:
-
Object
- Object
- BSON::Code
- Defined in:
- lib/bson/types/code.rb
Overview
JavaScript code to be evaluated by MongoDB.
Instance Attribute Summary collapse
-
#code ⇒ Object
Hash mapping identifiers to their values.
-
#scope ⇒ Object
Hash mapping identifiers to their values.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(code, scope = {}) ⇒ Code
constructor
Wrap code to be evaluated by MongoDB.
- #inspect ⇒ Object
- #length ⇒ Object
- #to_bson_code ⇒ Object
Constructor Details
#initialize(code, scope = {}) ⇒ Code
Wrap code to be evaluated by MongoDB.
14 15 16 17 18 19 20 21 |
# File 'lib/bson/types/code.rb', line 14 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
#code ⇒ Object
Hash mapping identifiers to their values
7 8 9 |
# File 'lib/bson/types/code.rb', line 7 def code @code end |
#scope ⇒ Object
Hash mapping identifiers to their values
7 8 9 |
# File 'lib/bson/types/code.rb', line 7 def scope @scope end |
Instance Method Details
#==(other) ⇒ Object
27 28 29 30 |
# File 'lib/bson/types/code.rb', line 27 def ==(other) self.class == other.class && @code == other.code && @scope == other.scope end |
#inspect ⇒ Object
32 33 34 |
# File 'lib/bson/types/code.rb', line 32 def inspect "<BSON::Code:#{object_id} @data=\"#{@code}\" @scope=\"#{@scope.inspect}\">" end |
#length ⇒ Object
23 24 25 |
# File 'lib/bson/types/code.rb', line 23 def length @code.length end |
#to_bson_code ⇒ Object
36 37 38 |
# File 'lib/bson/types/code.rb', line 36 def to_bson_code self end |