struct

Messages::Attachment

Inherits BSON::Serializable < Struct < Value < Object

Constructors

new(filename : String, bytes : Slice(UInt8))
Source
new(bson : BSON)

Allocate an instance and copies data from a BSON struct.

class User
  include BSON::Serializable
  property name : String
end

data = BSON.new
data["name"] = "John"
User.new(data)
Source

Class methods

from_bson(bson : BSON)

NOTE: See self.new.

Source

Instance methods

bytes
Source
bytes=(bytes : Bytes)
Source
filename
Source
filename=(filename : String)
Source
to_bson(bson = BSON.new)

Converts to a BSON representation.

user = User.new name: "John"
bson = user.to_bson
Source