Class: BSON::Code
Instance Method Summary collapse
- #==(other) ⇒ Object
- #code ⇒ Object
-
#initialize(code, scope = {}) ⇒ Code
constructor
Wrap code to be evaluated by MongoDB.
- #inspect ⇒ Object
- #length ⇒ Object
- #scope ⇒ Object
- #to_bson ⇒ Object (also: #to_bson_code)
- #to_s ⇒ Object
Constructor Details
#initialize(code, scope = {}) ⇒ Code
Wrap code to be evaluated by MongoDB.
70 71 72 73 74 75 |
# File 'lib/jmongo/mongo/bson.rb', line 70 def initialize(code, scope={}) unless code.is_a?(String) raise ArgumentError, "BSON::Code must be in the form of a String; #{code.class} is not accepted." end @bson_code = BsonCode.new(code, scope.to_bson) end |
Instance Method Details
#==(other) ⇒ Object
89 90 91 92 |
# File 'lib/jmongo/mongo/bson.rb', line 89 def ==(other) self.class == other.class && code == other.code && scope == other.scope end |
#code ⇒ Object
77 78 79 |
# File 'lib/jmongo/mongo/bson.rb', line 77 def code @bson_code.code end |
#inspect ⇒ Object
94 95 96 |
# File 'lib/jmongo/mongo/bson.rb', line 94 def inspect "<BSON::Code:#{object_id} @code=\"#{code}\" @scope=\"#{scope.inspect}\">" end |
#length ⇒ Object
85 86 87 |
# File 'lib/jmongo/mongo/bson.rb', line 85 def length code.length end |
#scope ⇒ Object
81 82 83 |
# File 'lib/jmongo/mongo/bson.rb', line 81 def scope @bson_code.scope end |
#to_bson ⇒ Object Also known as: to_bson_code
102 103 104 |
# File 'lib/jmongo/mongo/bson.rb', line 102 def to_bson @bson_code end |
#to_s ⇒ Object
98 99 100 |
# File 'lib/jmongo/mongo/bson.rb', line 98 def to_s code.to_s end |