bson 1.12.5-java → 2.0.0-java
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of bson might be problematic. Click here for more details.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGELOG.md +80 -0
- data/CONTRIBUTING.md +42 -0
- data/NOTICE +2 -0
- data/README.md +190 -0
- data/Rakefile +109 -0
- data/lib/bson-ruby.jar +0 -0
- data/lib/bson.rb +60 -87
- data/lib/bson/array.rb +104 -0
- data/lib/bson/binary.rb +193 -0
- data/lib/bson/boolean.rb +48 -0
- data/lib/bson/code.rb +109 -0
- data/lib/bson/code_with_scope.rb +120 -0
- data/lib/bson/document.rb +549 -0
- data/lib/bson/encodable.rb +86 -0
- data/lib/bson/environment.rb +98 -0
- data/lib/bson/false_class.rb +61 -0
- data/lib/bson/float.rb +82 -0
- data/lib/bson/hash.rb +84 -0
- data/lib/bson/int32.rb +59 -0
- data/lib/bson/int64.rb +59 -0
- data/lib/bson/integer.rb +185 -0
- data/lib/bson/json.rb +37 -0
- data/lib/bson/max_key.rb +70 -0
- data/lib/bson/min_key.rb +70 -0
- data/lib/bson/nil_class.rb +70 -0
- data/lib/bson/object_id.rb +395 -0
- data/lib/bson/regexp.rb +124 -0
- data/lib/bson/registry.rb +70 -0
- data/lib/bson/specialized.rb +74 -0
- data/lib/bson/string.rb +203 -0
- data/lib/bson/symbol.rb +87 -0
- data/lib/bson/time.rb +72 -0
- data/lib/bson/timestamp.rb +113 -0
- data/lib/bson/true_class.rb +61 -0
- data/lib/bson/undefined.rb +74 -0
- data/lib/bson/version.rb +17 -0
- data/spec/bson/array_spec.rb +58 -0
- data/spec/bson/binary_spec.rb +115 -0
- data/spec/bson/boolean_spec.rb +48 -0
- data/spec/bson/code_spec.rb +42 -0
- data/spec/bson/code_with_scope_spec.rb +74 -0
- data/spec/bson/document_spec.rb +778 -0
- data/spec/bson/false_class_spec.rb +28 -0
- data/spec/bson/float_spec.rb +29 -0
- data/spec/bson/hash_spec.rb +56 -0
- data/spec/bson/int32_spec.rb +28 -0
- data/spec/bson/int64_spec.rb +28 -0
- data/spec/bson/integer_spec.rb +76 -0
- data/spec/bson/json_spec.rb +53 -0
- data/spec/bson/max_key_spec.rb +75 -0
- data/spec/bson/min_key_spec.rb +75 -0
- data/spec/bson/nil_class_spec.rb +29 -0
- data/spec/bson/object_id_spec.rb +527 -0
- data/spec/bson/regexp_spec.rb +89 -0
- data/spec/bson/registry_spec.rb +55 -0
- data/spec/bson/string_spec.rb +298 -0
- data/spec/bson/symbol_spec.rb +55 -0
- data/spec/bson/time_spec.rb +43 -0
- data/spec/bson/timestamp_spec.rb +74 -0
- data/spec/bson/true_class_spec.rb +28 -0
- data/spec/bson/undefined_spec.rb +29 -0
- data/{lib/bson/types/dbref.rb → spec/bson_spec.rb} +22 -16
- data/spec/spec_helper.rb +32 -0
- data/spec/support/shared_examples.rb +95 -0
- metadata +116 -48
- metadata.gz.sig +1 -1
- data/VERSION +0 -1
- data/bin/b2json +0 -63
- data/bin/j2bson +0 -64
- data/bson.gemspec +0 -34
- data/ext/jbson/lib/java-bson.jar +0 -0
- data/ext/jbson/target/jbson.jar +0 -0
- data/lib/bson/bson_c.rb +0 -37
- data/lib/bson/bson_java.rb +0 -49
- data/lib/bson/bson_ruby.rb +0 -645
- data/lib/bson/byte_buffer.rb +0 -241
- data/lib/bson/exceptions.rb +0 -37
- data/lib/bson/grow.rb +0 -173
- data/lib/bson/ordered_hash.rb +0 -197
- data/lib/bson/support/hash_with_indifferent_access.rb +0 -174
- data/lib/bson/types/binary.rb +0 -52
- data/lib/bson/types/code.rb +0 -55
- data/lib/bson/types/min_max_keys.rb +0 -56
- data/lib/bson/types/object_id.rb +0 -226
- data/lib/bson/types/regex.rb +0 -116
- data/lib/bson/types/timestamp.rb +0 -72
data/lib/bson/ordered_hash.rb
DELETED
@@ -1,197 +0,0 @@
|
|
1
|
-
# Copyright (C) 2009-2013 MongoDB, Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
# A hash in which the order of keys are preserved.
|
16
|
-
#
|
17
|
-
# Under Ruby 1.9 and greater, this class has no added methods because Ruby's
|
18
|
-
# Hash already keeps its keys ordered by order of insertion.
|
19
|
-
|
20
|
-
module BSON
|
21
|
-
class OrderedHash < Hash
|
22
|
-
|
23
|
-
def ==(other)
|
24
|
-
begin
|
25
|
-
case other
|
26
|
-
when BSON::OrderedHash
|
27
|
-
keys == other.keys && values == other.values
|
28
|
-
else
|
29
|
-
super
|
30
|
-
end
|
31
|
-
rescue
|
32
|
-
false
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
# Allows activesupport Array#extract_options! to extract options
|
37
|
-
# when they are instance of BSON::OrderedHash
|
38
|
-
#
|
39
|
-
# @return [true, false] true if options can be extracted
|
40
|
-
def extractable_options?
|
41
|
-
instance_of?(BSON::OrderedHash)
|
42
|
-
end
|
43
|
-
|
44
|
-
def reject
|
45
|
-
return to_enum(:reject) unless block_given?
|
46
|
-
dup.tap {|hash| hash.reject!{|k, v| yield k, v}}
|
47
|
-
end
|
48
|
-
|
49
|
-
def select
|
50
|
-
return to_enum(:select) unless block_given?
|
51
|
-
dup.tap {|hash| hash.reject!{|k, v| ! yield k, v}}
|
52
|
-
end
|
53
|
-
|
54
|
-
# We only need the body of this class if the RUBY_VERSION is before 1.9
|
55
|
-
if RUBY_VERSION < '1.9'
|
56
|
-
attr_accessor :ordered_keys
|
57
|
-
|
58
|
-
def self.[] *args
|
59
|
-
oh = BSON::OrderedHash.new
|
60
|
-
if Hash === args[0]
|
61
|
-
oh.merge! args[0]
|
62
|
-
elsif (args.size % 2) != 0
|
63
|
-
raise ArgumentError, "odd number of elements for Hash"
|
64
|
-
else
|
65
|
-
0.step(args.size - 1, 2) do |key|
|
66
|
-
value = key + 1
|
67
|
-
oh[args[key]] = args[value]
|
68
|
-
end
|
69
|
-
end
|
70
|
-
oh
|
71
|
-
end
|
72
|
-
|
73
|
-
def initialize(*a, &b)
|
74
|
-
@ordered_keys = []
|
75
|
-
super
|
76
|
-
end
|
77
|
-
|
78
|
-
def yaml_initialize(tag, val)
|
79
|
-
@ordered_keys = []
|
80
|
-
super
|
81
|
-
end
|
82
|
-
|
83
|
-
def keys
|
84
|
-
@ordered_keys.dup
|
85
|
-
end
|
86
|
-
|
87
|
-
def []=(key, value)
|
88
|
-
unless has_key?(key)
|
89
|
-
@ordered_keys << key
|
90
|
-
end
|
91
|
-
super(key, value)
|
92
|
-
end
|
93
|
-
|
94
|
-
def each
|
95
|
-
@ordered_keys.each { |k| yield k, self[k] }
|
96
|
-
self
|
97
|
-
end
|
98
|
-
alias :each_pair :each
|
99
|
-
|
100
|
-
def to_a
|
101
|
-
@ordered_keys.map { |k| [k, self[k]] }
|
102
|
-
end
|
103
|
-
|
104
|
-
def values
|
105
|
-
collect { |k, v| v }
|
106
|
-
end
|
107
|
-
|
108
|
-
def replace(other)
|
109
|
-
@ordered_keys.replace(other.keys)
|
110
|
-
super
|
111
|
-
end
|
112
|
-
|
113
|
-
def merge(other)
|
114
|
-
oh = self.dup
|
115
|
-
oh.merge!(other)
|
116
|
-
oh
|
117
|
-
end
|
118
|
-
|
119
|
-
def merge!(other)
|
120
|
-
@ordered_keys += other.keys # unordered if not an BSON::OrderedHash
|
121
|
-
@ordered_keys.uniq!
|
122
|
-
super(other)
|
123
|
-
end
|
124
|
-
|
125
|
-
alias :update :merge!
|
126
|
-
|
127
|
-
def dup
|
128
|
-
result = OrderedHash.new
|
129
|
-
@ordered_keys.each do |key|
|
130
|
-
result[key] = self[key]
|
131
|
-
end
|
132
|
-
result
|
133
|
-
end
|
134
|
-
|
135
|
-
def inspect
|
136
|
-
str = "#<BSON::OrderedHash:0x#{self.object_id.to_s(16)} {"
|
137
|
-
str << (@ordered_keys || []).collect { |k| "\"#{k}\"=>#{self.[](k).inspect}" }.join(", ")
|
138
|
-
str << '}>'
|
139
|
-
end
|
140
|
-
|
141
|
-
def delete(key, &block)
|
142
|
-
@ordered_keys.delete(key) if @ordered_keys
|
143
|
-
super
|
144
|
-
end
|
145
|
-
|
146
|
-
def delete_if(&block)
|
147
|
-
keys.each do |key|
|
148
|
-
if yield key, self[key]
|
149
|
-
delete(key)
|
150
|
-
end
|
151
|
-
end
|
152
|
-
self
|
153
|
-
end
|
154
|
-
|
155
|
-
def reject!
|
156
|
-
return to_enum(:reject!) unless block_given?
|
157
|
-
raise "can't modify frozen BSON::OrderedHash" if frozen?
|
158
|
-
keys = @ordered_keys.dup
|
159
|
-
@ordered_keys.each do |k|
|
160
|
-
if yield k, self[k]
|
161
|
-
keys.delete(k)
|
162
|
-
end
|
163
|
-
end
|
164
|
-
keys == @ordered_keys ? nil : @ordered_keys = keys
|
165
|
-
end
|
166
|
-
|
167
|
-
def clear
|
168
|
-
super
|
169
|
-
@ordered_keys = []
|
170
|
-
end
|
171
|
-
|
172
|
-
def initialize_copy(original)
|
173
|
-
super
|
174
|
-
@ordered_keys = original.ordered_keys.dup
|
175
|
-
end
|
176
|
-
|
177
|
-
if RUBY_VERSION =~ /1.8.6/
|
178
|
-
def hash
|
179
|
-
code = 17
|
180
|
-
each_pair do |key, value|
|
181
|
-
code = 37 * code + key.hash
|
182
|
-
code = 37 * code + value.hash
|
183
|
-
end
|
184
|
-
code & 0x7fffffff
|
185
|
-
end
|
186
|
-
|
187
|
-
def eql?(o)
|
188
|
-
if o.instance_of? BSON::OrderedHash
|
189
|
-
self.hash == o.hash
|
190
|
-
else
|
191
|
-
false
|
192
|
-
end
|
193
|
-
end
|
194
|
-
end
|
195
|
-
end
|
196
|
-
end
|
197
|
-
end
|
@@ -1,174 +0,0 @@
|
|
1
|
-
# Copyright (C) 2009-2013 MongoDB, Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
require 'active_support'
|
16
|
-
begin
|
17
|
-
require 'active_support/hash_with_indifferent_access'
|
18
|
-
rescue LoadError
|
19
|
-
# For ActiveSupport 2
|
20
|
-
require 'active_support/core_ext/hash/indifferent_access'
|
21
|
-
end
|
22
|
-
|
23
|
-
module ActiveSupport
|
24
|
-
class HashWithIndifferentAccess < Hash
|
25
|
-
def extractable_options?
|
26
|
-
true
|
27
|
-
end
|
28
|
-
|
29
|
-
def initialize(constructor = {})
|
30
|
-
if constructor.is_a?(Hash)
|
31
|
-
super()
|
32
|
-
update(constructor)
|
33
|
-
else
|
34
|
-
super(constructor)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def default(key = nil)
|
39
|
-
if key.is_a?(Symbol) && include?(key = key.to_s)
|
40
|
-
self[key]
|
41
|
-
else
|
42
|
-
super
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def self.new_from_hash_copying_default(hash)
|
47
|
-
ActiveSupport::HashWithIndifferentAccess.new(hash).tap do |new_hash|
|
48
|
-
new_hash.default = hash.default
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def reject
|
53
|
-
return to_enum(:reject) unless block_given?
|
54
|
-
dup.tap {|hash| hash.reject!{|k, v| yield k, v}}
|
55
|
-
end
|
56
|
-
|
57
|
-
def select
|
58
|
-
return to_enum(:select) unless block_given?
|
59
|
-
dup.tap {|hash| hash.reject!{|k, v| ! yield k, v}}
|
60
|
-
end
|
61
|
-
|
62
|
-
alias_method :regular_writer, :[]= unless method_defined?(:regular_writer)
|
63
|
-
alias_method :regular_update, :update unless method_defined?(:regular_update)
|
64
|
-
|
65
|
-
# Assigns a new value to the hash:
|
66
|
-
#
|
67
|
-
# hash = HashWithIndifferentAccess.new
|
68
|
-
# hash[:key] = "value"
|
69
|
-
#
|
70
|
-
def []=(key, value)
|
71
|
-
regular_writer(convert_key(key), convert_value(value))
|
72
|
-
end
|
73
|
-
|
74
|
-
# Updates the instantized hash with values from the second:
|
75
|
-
#
|
76
|
-
# hash_1 = HashWithIndifferentAccess.new
|
77
|
-
# hash_1[:key] = "value"
|
78
|
-
#
|
79
|
-
# hash_2 = HashWithIndifferentAccess.new
|
80
|
-
# hash_2[:key] = "New Value!"
|
81
|
-
#
|
82
|
-
# hash_1.update(hash_2) # => {"key"=>"New Value!"}
|
83
|
-
#
|
84
|
-
def update(other_hash)
|
85
|
-
other_hash.each_pair { |key, value| regular_writer(convert_key(key), convert_value(value)) }
|
86
|
-
self
|
87
|
-
end
|
88
|
-
|
89
|
-
alias_method :merge!, :update
|
90
|
-
|
91
|
-
# Checks the hash for a key matching the argument passed in:
|
92
|
-
#
|
93
|
-
# hash = HashWithIndifferentAccess.new
|
94
|
-
# hash["key"] = "value"
|
95
|
-
# hash.key? :key # => true
|
96
|
-
# hash.key? "key" # => true
|
97
|
-
#
|
98
|
-
def key?(key)
|
99
|
-
super(convert_key(key))
|
100
|
-
end
|
101
|
-
|
102
|
-
alias_method :include?, :key?
|
103
|
-
alias_method :has_key?, :key?
|
104
|
-
alias_method :member?, :key?
|
105
|
-
|
106
|
-
# Fetches the value for the specified key, same as doing hash[key]
|
107
|
-
def fetch(key, *extras)
|
108
|
-
super(convert_key(key), *extras)
|
109
|
-
end
|
110
|
-
|
111
|
-
# Returns an array of the values at the specified indices:
|
112
|
-
#
|
113
|
-
# hash = HashWithIndifferentAccess.new
|
114
|
-
# hash[:a] = "x"
|
115
|
-
# hash[:b] = "y"
|
116
|
-
# hash.values_at("a", "b") # => ["x", "y"]
|
117
|
-
#
|
118
|
-
def values_at(*indices)
|
119
|
-
indices.collect {|key| self[convert_key(key)]}
|
120
|
-
end
|
121
|
-
|
122
|
-
# Returns an exact copy of the hash.
|
123
|
-
def dup
|
124
|
-
HashWithIndifferentAccess.new(self)
|
125
|
-
end
|
126
|
-
|
127
|
-
# Merges the instantized and the specified hashes together, giving precedence to the values from the second hash
|
128
|
-
# Does not overwrite the existing hash.
|
129
|
-
def merge(hash)
|
130
|
-
self.dup.update(hash)
|
131
|
-
end
|
132
|
-
|
133
|
-
# Performs the opposite of merge, with the keys and values from the first hash taking precedence over the second.
|
134
|
-
# This overloaded definition prevents returning a regular hash, if reverse_merge is called on a HashWithDifferentAccess.
|
135
|
-
def reverse_merge(other_hash)
|
136
|
-
super self.class.new_from_hash_copying_default(other_hash)
|
137
|
-
end
|
138
|
-
|
139
|
-
def reverse_merge!(other_hash)
|
140
|
-
replace(reverse_merge( other_hash ))
|
141
|
-
end
|
142
|
-
|
143
|
-
# Removes a specified key from the hash.
|
144
|
-
def delete(key)
|
145
|
-
super(convert_key(key))
|
146
|
-
end
|
147
|
-
|
148
|
-
def stringify_keys!; self end
|
149
|
-
def stringify_keys; dup end
|
150
|
-
def symbolize_keys; to_hash.symbolize_keys end
|
151
|
-
def to_options!; self end
|
152
|
-
|
153
|
-
# Convert to a Hash with String keys.
|
154
|
-
def to_hash
|
155
|
-
Hash.new(default).merge!(self)
|
156
|
-
end
|
157
|
-
|
158
|
-
protected
|
159
|
-
def convert_key(key)
|
160
|
-
key.kind_of?(Symbol) ? key.to_s : key
|
161
|
-
end
|
162
|
-
|
163
|
-
def convert_value(value)
|
164
|
-
case value
|
165
|
-
when Hash
|
166
|
-
self.class.new_from_hash_copying_default(value)
|
167
|
-
when Array
|
168
|
-
value.collect { |e| e.is_a?(Hash) ? self.class.new_from_hash_copying_default(e) : e }
|
169
|
-
else
|
170
|
-
value
|
171
|
-
end
|
172
|
-
end
|
173
|
-
end
|
174
|
-
end
|
data/lib/bson/types/binary.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
# Copyright (C) 2009-2013 MongoDB, Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
require 'bson/byte_buffer'
|
16
|
-
|
17
|
-
module BSON
|
18
|
-
|
19
|
-
# An array of binary bytes with a MongoDB subtype. See the subtype
|
20
|
-
# constants for reference.
|
21
|
-
#
|
22
|
-
# Use this class when storing binary data in documents.
|
23
|
-
class Binary < ByteBuffer
|
24
|
-
|
25
|
-
SUBTYPE_SIMPLE = 0x00
|
26
|
-
SUBTYPE_BYTES = 0x02
|
27
|
-
SUBTYPE_UUID = 0x03
|
28
|
-
SUBTYPE_MD5 = 0x05
|
29
|
-
SUBTYPE_USER_DEFINED = 0x80
|
30
|
-
|
31
|
-
# One of the SUBTYPE_* constants. Default is SUBTYPE_BYTES.
|
32
|
-
attr_accessor :subtype
|
33
|
-
|
34
|
-
# Create a buffer for storing binary data in MongoDB.
|
35
|
-
#
|
36
|
-
# @param [Array, String] data to story as BSON binary. If a string is given, the on
|
37
|
-
# Ruby 1.9 it will be forced to the binary encoding.
|
38
|
-
# @param [Fixnum] subtype one of four values specifying a BSON binary subtype. Possible values are
|
39
|
-
# SUBTYPE_BYTES, SUBTYPE_UUID, SUBTYPE_MD5, and SUBTYPE_USER_DEFINED.
|
40
|
-
#
|
41
|
-
# @see http://www.mongodb.org/display/DOCS/BSON#BSON-noteondatabinary BSON binary subtypes.
|
42
|
-
def initialize(data=[], subtype=SUBTYPE_SIMPLE)
|
43
|
-
super(data)
|
44
|
-
@subtype = subtype
|
45
|
-
end
|
46
|
-
|
47
|
-
def inspect
|
48
|
-
"<BSON::Binary:#{object_id}>"
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
end
|
data/lib/bson/types/code.rb
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
# Copyright (C) 2009-2013 MongoDB, Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
module BSON
|
16
|
-
|
17
|
-
# JavaScript code to be evaluated by MongoDB.
|
18
|
-
class Code
|
19
|
-
|
20
|
-
# Hash mapping identifiers to their values
|
21
|
-
attr_accessor :scope, :code
|
22
|
-
|
23
|
-
# Wrap code to be evaluated by MongoDB.
|
24
|
-
#
|
25
|
-
# @param [String] code the JavaScript code.
|
26
|
-
# @param [Hash] scope a document mapping identifiers to values, which
|
27
|
-
# represent the scope in which the code is to be executed.
|
28
|
-
def initialize(code, scope={})
|
29
|
-
@code = code
|
30
|
-
@scope = scope
|
31
|
-
|
32
|
-
unless @code.is_a?(String)
|
33
|
-
raise ArgumentError, "BSON::Code must be in the form of a String; #{@code.class} is not allowed."
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def length
|
38
|
-
@code.length
|
39
|
-
end
|
40
|
-
|
41
|
-
def ==(other)
|
42
|
-
self.class == other.class &&
|
43
|
-
@code == other.code && @scope == other.scope
|
44
|
-
end
|
45
|
-
|
46
|
-
def inspect
|
47
|
-
"<BSON::Code:#{object_id} @data=\"#{@code}\" @scope=\"#{@scope.inspect}\">"
|
48
|
-
end
|
49
|
-
|
50
|
-
def to_bson_code
|
51
|
-
self
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|
55
|
-
end
|