Last active
December 24, 2015 21:19
-
-
Save cheald/6865088 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def initialize(initial_data="", max_size=DEFAULT_MAX_BSON_SIZE) | |
puts "---" | |
puts "initial data is: #{initial_data.class}" | |
@str = case initial_data | |
when String then | |
puts "Branched to String" | |
if initial_data.respond_to?(:force_encoding) | |
initial_data.force_encoding('binary') | |
else | |
initial_data | |
end | |
when BSON::ByteBuffer then | |
puts "Branched to BSON::ByteBuffer" | |
initial_data.to_a.pack('C*') | |
else | |
puts "Branched to else" | |
initial_data.pack('C*') | |
end | |
raise "Got an array!! #{@str.inspect}" if @str.is_a? Array | |
@cursor = @str.length | |
@max_size = max_size | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
initial data is: String | |
Branched to String | |
--- | |
initial data is: String | |
Branched to String | |
--- | |
initial data is: String | |
Branched to String | |
--- | |
initial data is: String | |
Branched to String | |
--- | |
initial data is: Array | |
Branched to String | |
F | |
Failures: | |
1) Admin::StatsController#database should get an HTML template | |
Failure/Error: Unable to find matching line from backtrace | |
RuntimeError: | |
Got an array!! [0, 0, 0, 0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment