Skip to content
This repository was archived by the owner on Oct 7, 2022. It is now read-only.

Commit 91d1657

Browse files
author
Andrej Jančič
committed
add galleries extend contents
1 parent 8d4289b commit 91d1657

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed

lib/creatubbles/base_collection.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,9 @@ def find(id)
1717
res = @connection.get("#{self.class.type_name}/#{id}")
1818
Creatubbles.instantiate_object_from_response(res, @connection)
1919
end
20+
21+
def init_objects response
22+
Creatubbles.instantiate_objects_from_response(response, @connection)
23+
end
24+
2025
end

lib/creatubbles/contents.rb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ class Creatubbles::Contents < Creatubbles::BaseCollection
44

55
define_type_name 'contents'
66

7+
def index params_hash = {"query": nil}
8+
params_hash.stringify_keys!.slice!("query")
9+
init_objects @connection.get("contents?#{params_hash.to_param}")
10+
end
11+
712
def recent
813
init_objects @connection.get('contents/recent')
914
end
@@ -20,10 +25,4 @@ def followed
2025
init_objects @connection.get('contents/followed')
2126
end
2227

23-
private
24-
25-
def init_objects response
26-
Creatubbles.instantiate_objects_from_response(response, @connection)
27-
end
28-
2928
end

lib/creatubbles/galleries.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,25 @@
33
class Creatubbles::Galleries < Creatubbles::BaseCollection
44

55
define_type_name 'galleries'
6+
7+
def featured
8+
init_objects @connection.get('featured_galleries')
9+
end
10+
11+
def owned_by_user user_id
12+
init_objects @connection.get("users/#{user_id}/galleries")
13+
end
14+
15+
def mine
16+
init_objects @connection.get("users/me/galleries")
17+
end
18+
19+
def mine_favorite
20+
init_objects @connection.get("users/me/favorite_galleries")
21+
end
22+
23+
def containing_creation creation_id
24+
init_objects @connection.get("creations/#{creation_id}/galleries")
25+
end
26+
627
end

0 commit comments

Comments
 (0)