Class: Appwrite::Models::Collection

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, created_at:, updated_at:, permissions:, database_id:, name:, description:, enabled:, document_security:, attributes:, indexes:, bytes_max:, bytes_used:) ⇒ Collection

Returns a new instance of Collection.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/appwrite/models/collection.rb', line 20

def initialize(
    id:,
    created_at:,
    updated_at:,
    permissions:,
    database_id:,
    name:,
    description:,
    enabled:,
    document_security:,
    attributes:,
    indexes:,
    bytes_max:,
    bytes_used:
)
    @id = id
    @created_at = created_at
    @updated_at = updated_at
    @permissions = permissions
    @database_id = database_id
    @name = name
    @description = description
    @enabled = enabled
    @document_security = document_security
    @attributes = attributes
    @indexes = indexes
    @bytes_max = bytes_max
    @bytes_used = bytes_used
end

Instance Attribute Details

#attributes ⇒ Object (readonly)

Returns the value of attribute attributes.



15
16
17
# File 'lib/appwrite/models/collection.rb', line 15

def attributes
  @attributes
end

#bytes_max ⇒ Object (readonly)

Returns the value of attribute bytes_max.



17
18
19
# File 'lib/appwrite/models/collection.rb', line 17

def bytes_max
  @bytes_max
end

#bytes_used ⇒ Object (readonly)

Returns the value of attribute bytes_used.



18
19
20
# File 'lib/appwrite/models/collection.rb', line 18

def bytes_used
  @bytes_used
end

#created_at ⇒ Object (readonly)

Returns the value of attribute created_at.



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

def created_at
  @created_at
end

#database_id ⇒ Object (readonly)

Returns the value of attribute database_id.



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

def database_id
  @database_id
end

#description ⇒ Object (readonly)

Returns the value of attribute description.



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

def description
  @description
end

#document_security ⇒ Object (readonly)

Returns the value of attribute document_security.



14
15
16
# File 'lib/appwrite/models/collection.rb', line 14

def document_security
  @document_security
end

#enabled ⇒ Object (readonly)

Returns the value of attribute enabled.



13
14
15
# File 'lib/appwrite/models/collection.rb', line 13

def enabled
  @enabled
end

#id ⇒ Object (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#indexes ⇒ Object (readonly)

Returns the value of attribute indexes.



16
17
18
# File 'lib/appwrite/models/collection.rb', line 16

def indexes
  @indexes
end

#name ⇒ Object (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#permissions ⇒ Object (readonly)

Returns the value of attribute permissions.



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

def permissions
  @permissions
end

#updated_at ⇒ Object (readonly)

Returns the value of attribute updated_at.



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

def updated_at
  @updated_at
end

Class Method Details

.from(map:) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/appwrite/models/collection.rb', line 50

def self.from(map:)
    map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "$permissions" => [], "databaseId" => "", "name" => "", "description" => "", "enabled" => true, "documentSecurity" => false, "attributes" => [], "indexes" => [], "bytesMax" => 0, "bytesUsed" => 0 }.merge(map)
    Collection.new(
        id: map["$id"],
        created_at: map["$createdAt"],
        updated_at: map["$updatedAt"],
        permissions: map["$permissions"],
        database_id: map["databaseId"],
        name: map["name"],
        description: map["description"],
        enabled: map["enabled"],
        document_security: map["documentSecurity"],
        attributes: map["attributes"],
        indexes: map["indexes"].map { |it| Index.from(map: it) },
        bytes_max: map["bytesMax"],
        bytes_used: map["bytesUsed"]
    )
end

Instance Method Details

#to_map ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/appwrite/models/collection.rb', line 69

def to_map
    {
        "$id": @id,
        "$createdAt": @created_at,
        "$updatedAt": @updated_at,
        "$permissions": @permissions,
        "databaseId": @database_id,
        "name": @name,
        "description": @description,
        "enabled": @enabled,
        "documentSecurity": @document_security,
        "attributes": @attributes,
        "indexes": @indexes.map { |it| it.to_map },
        "bytesMax": @bytes_max,
        "bytesUsed": @bytes_used
    }
end