Skip to content

Instantly share code, notes, and snippets.

@cheald
Last active December 24, 2015 21:19
Show Gist options
  • Save cheald/6865088 to your computer and use it in GitHub Desktop.
Save cheald/6865088 to your computer and use it in GitHub Desktop.
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
---
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