Class: Appwrite::Models::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/appwrite/models/document.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, collection:, read:, write:, data:) ⇒ Document

Returns a new instance of Document.



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/appwrite/models/document.rb', line 11

def initialize(
    id:,
    collection:,
    read:,
    write:,
    data:
)
    @id = id
    @collection = collection
    @read = read
    @write = write
    @data = data
end

Instance Attribute Details

#collectionObject (readonly)

Returns the value of attribute collection.



7
8
9
# File 'lib/appwrite/models/document.rb', line 7

def collection
  @collection
end

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/appwrite/models/document.rb', line 6

def id
  @id
end

#readObject (readonly)

Returns the value of attribute read.



8
9
10
# File 'lib/appwrite/models/document.rb', line 8

def read
  @read
end

#writeObject (readonly)

Returns the value of attribute write.



9
10
11
# File 'lib/appwrite/models/document.rb', line 9

def write
  @write
end

Class Method Details

.from(map:) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/appwrite/models/document.rb', line 25

def self.from(map:)
    Document.new(
        id: map["$id"],
        collection: map["$collection"],
        read: map["$read"],
        write: map["$write"],
        data: map["data"]
    )
end

Instance Method Details

#convert_to(from_json) ⇒ Object



45
46
47
# File 'lib/appwrite/models/document.rb', line 45

def convert_to(from_json)
    from_json.call(data)
end

#to_mapObject



35
36
37
38
39
40
41
42
43
# File 'lib/appwrite/models/document.rb', line 35

def to_map
    {
        "$id": @id,
        "$collection": @collection,
        "$read": @read,
        "$write": @write,
        "data": @data
    }
end