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_id:, database_id:, created_at:, updated_at:, permissions:, data:) ⇒ Document

Returns a new instance of Document.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/appwrite/models/document.rb', line 14

def initialize(
    id:,
    collection_id:,
    database_id:,
    created_at:,
    updated_at:,
    permissions:,
    data:
)
    @id = id
    @collection_id = collection_id
    @database_id = database_id
    @created_at = created_at
    @updated_at = updated_at
    @permissions = permissions
    @data = data
end

Instance Attribute Details

#collection_idObject (readonly)

Returns the value of attribute collection_id.



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

def collection_id
  @collection_id
end

#created_atObject (readonly)

Returns the value of attribute created_at.



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

def created_at
  @created_at
end

#dataObject (readonly)

Returns the value of attribute data.



12
13
14
# File 'lib/appwrite/models/document.rb', line 12

def data
  @data
end

#database_idObject (readonly)

Returns the value of attribute database_id.



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

def database_id
  @database_id
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#permissionsObject (readonly)

Returns the value of attribute permissions.



11
12
13
# File 'lib/appwrite/models/document.rb', line 11

def permissions
  @permissions
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



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

def updated_at
  @updated_at
end

Class Method Details

.from(map:) ⇒ Object



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

def self.from(map:)
    Document.new(
        id: map["$id"],
        collection_id: map["$collectionId"],
        database_id: map["$databaseId"],
        created_at: map["$createdAt"],
        updated_at: map["$updatedAt"],
        permissions: map["$permissions"],
        data: map
    )
end

Instance Method Details

#convert_to(from_json) ⇒ Object



56
57
58
# File 'lib/appwrite/models/document.rb', line 56

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

#to_mapObject



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/appwrite/models/document.rb', line 44

def to_map
    {
        "$id": @id,
        "$collectionId": @collection_id,
        "$databaseId": @database_id,
        "$createdAt": @created_at,
        "$updatedAt": @updated_at,
        "$permissions": @permissions,
        "data": @data
    }
end