Class: KintoBox::KintoBucket
- Inherits:
-
Object
- Object
- KintoBox::KintoBucket
show all
- Includes:
- KintoObject
- Defined in:
- lib/kinto_box/kinto_bucket.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
#add_permission, #delete, #exists?, #info, #permissions, #replace_permission, #update
Constructor Details
#initialize(client, bucket_id) ⇒ KintoBucket
Returns a new instance of KintoBucket.
11
12
13
14
15
16
17
|
# File 'lib/kinto_box/kinto_bucket.rb', line 11
def initialize (client, bucket_id)
raise ArgumentError if bucket_id.nil? || client.nil?
@kinto_client = client
@id = bucket_id
@url_path = "/buckets/#{@id}"
end
|
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
8
9
10
|
# File 'lib/kinto_box/kinto_bucket.rb', line 8
def id
@id
end
|
#kinto_client ⇒ Object
Returns the value of attribute kinto_client.
9
10
11
|
# File 'lib/kinto_box/kinto_bucket.rb', line 9
def kinto_client
@kinto_client
end
|
Instance Method Details
#collection(collection_id) ⇒ Object
27
28
29
30
|
# File 'lib/kinto_box/kinto_bucket.rb', line 27
def collection (collection_id)
@collection = KintoCollection.new(self, collection_id)
@collection
end
|
#create_collection(collection_id) ⇒ Object
37
38
39
40
|
# File 'lib/kinto_box/kinto_bucket.rb', line 37
def create_collection(collection_id)
@kinto_client.post("#{@url_path}/collections", { 'data' => { 'id' => collection_id}})
collection(collection_id)
end
|
#create_group(group_id, members) ⇒ Object
42
43
44
45
46
|
# File 'lib/kinto_box/kinto_bucket.rb', line 42
def create_group(group_id, members)
members = [members] unless members.is_a?(Array)
@kinto_client.put("#{@url_path}/groups/#{group_id}", { 'data' => { 'members' => members}})
group(group_id)
end
|
#delete_collections ⇒ Object
48
49
50
|
# File 'lib/kinto_box/kinto_bucket.rb', line 48
def delete_collections
@kinto_client.delete("#{@url_path}/collections")
end
|
#group(group_id) ⇒ Object
32
33
34
35
|
# File 'lib/kinto_box/kinto_bucket.rb', line 32
def group(group_id)
@group = KintoGroup.new(self, group_id)
@group
end
|
#list_collections ⇒ Object
19
20
21
|
# File 'lib/kinto_box/kinto_bucket.rb', line 19
def list_collections
@kinto_client.get("#{@url_path}/collections")
end
|
#list_groups ⇒ Object
23
24
25
|
# File 'lib/kinto_box/kinto_bucket.rb', line 23
def list_groups
@kinto_client.get("#{@url_path}/groups")
end
|