Parent

Class/Module Index [+]

Quicksearch

Moped::BSON::Code

Attributes

code[R]
scope[R]

Public Class Methods

__bson_load__(io) click to toggle source
# File lib/moped/bson/code.rb, line 26
def __bson_load__(io)
  code = io.read(*io.read(4).unpack(INT32_PACK)).from_utf8_binary.chop!
  new code
end
new(code, scope=nil) click to toggle source
# File lib/moped/bson/code.rb, line 7
def initialize(code, scope=nil)
  @code = code
  @scope = scope
end

Public Instance Methods

==(other) click to toggle source
# File lib/moped/bson/code.rb, line 16
def ==(other)
  BSON::Code === other && code == other.code && scope == other.scope
end
Also aliased as: eql?
__bson_dump__(io, key) click to toggle source
# File lib/moped/bson/code.rb, line 32
def __bson_dump__(io, key)
  if scoped?
    io << Types::CODE_WITH_SCOPE
    io << key.to_bson_cstring

    code_start = io.bytesize

    io << START_LENGTH

    data = code.to_utf8_binary
    io << [data.bytesize+1].pack(INT32_PACK)
    io << data
    io << NULL_BYTE

    scope.__bson_dump__(io)

    io[code_start, 4] = [io.bytesize - code_start].pack(INT32_PACK)

  else
    io << Types::CODE
    io << key.to_bson_cstring

    data = code.to_utf8_binary
    io << [data.bytesize+1].pack(INT32_PACK)
    io << data
    io << NULL_BYTE
  end
end
eql?(other) click to toggle source
Alias for: ==
hash() click to toggle source
# File lib/moped/bson/code.rb, line 21
def hash
  [code, scope].hash
end
scoped?() click to toggle source
# File lib/moped/bson/code.rb, line 12
def scoped?
  !!scope
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.