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.
69 70 71 72 73 74 |
# File 'lib/jmongo/mongo/bson.rb', line 69 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
88 89 90 91 |
# File 'lib/jmongo/mongo/bson.rb', line 88 def ==(other) self.class == other.class && code == other.code && scope == other.scope end |
#code ⇒ Object
76 77 78 |
# File 'lib/jmongo/mongo/bson.rb', line 76 def code @bson_code.code end |
#inspect ⇒ Object
93 94 95 |
# File 'lib/jmongo/mongo/bson.rb', line 93 def inspect "<BSON::Code:#{object_id} @code=\"#{code}\" @scope=\"#{scope.inspect}\">" end |
#length ⇒ Object
84 85 86 |
# File 'lib/jmongo/mongo/bson.rb', line 84 def length code.length end |
#scope ⇒ Object
80 81 82 |
# File 'lib/jmongo/mongo/bson.rb', line 80 def scope @bson_code.scope end |
#to_bson ⇒ Object Also known as: to_bson_code
101 102 103 |
# File 'lib/jmongo/mongo/bson.rb', line 101 def to_bson @bson_code end |
#to_s ⇒ Object
97 98 99 |
# File 'lib/jmongo/mongo/bson.rb', line 97 def to_s code.to_s end |